如何使用回收器视图设置水平协调器布局



我需要水平实现我的布局,但现在它是线性布局,我不知道我的错误在哪里,但我需要你的帮助来解决这个问题

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    <android.support.v7.widget.RecyclerView
        android:id="@+id/card_view_recycler_list"
        android:scrollbars="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</android.support.design.widget.CoordinatorLayout>
在你的Java

类中输入以下代码:

 LinearLayoutManager lManager = new 
    LinearLayoutManager(getApplicationContext(),LinearLayoutManager.HORIZONTAL, false);
    lManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    mRecyclerView.setLayoutManager(lManager);

最新更新