我想创建一个RecyclerView,其中有两个CardView可以在其内部可见,并且可以水平滚动。类似于下面的图片。 如何用水平滚动来完成这个RecyclerView?
将LayoutManager设置为此代码可创建所需的格式,但它是垂直滚动的。
recyclerView.SetLayoutManager(new GridLayoutManager(Context, 2, GridLayoutManager.Vertical, false));
设置布局管理该代码创建一个不正确的格式,但它横向滚动。
recyclerView.SetLayoutManager(new GridLayoutManager(Context, 2, GridLayoutManager.Horizontal, false));
我的问题是我怎么创建两个CardViews是并排的,并且可以水平滚动的格式?
这里是CardView XML以防不时之需:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/cardView"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0000">
</RelativeLayout>
</android.support.v7.widget.CardView>
您是否尝试过使用LinearLayoutManager而不是GridLayoutManager? –