我想使用水平卷轴回收器。
对于这一点,我使用LinearLayoutManager (LinearLayoutManager.HORIZONTAL),这是可行的,但是对于这些项目获得了不同的缩进。
截图- https://i.stack.imgur.com/Mqp8A.png
碎片的布局:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_related"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingTop="20dp"
android:paddingBottom="20dp"
tools:listitem="@layout/item_2_lenta"/>
</LinearLayout>项目布局:
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="4dp"
app:cardBackgroundColor="#ff0">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
...
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>UPD
创建layoutManager
vRelatedStub.setOnInflateListener((viewStub, sView) -> {
vLabelRelated = sView.findViewById(R.id.label_related);
vListRelated = sView.findViewById(R.id.list_related);
vLoaderRelated = createLoaderView(sView, mAdapterRelated);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext(),
LinearLayoutManager.HORIZONTAL, false);
vListRelated.setLayoutManager(layoutManager);
vListRelated.setAdapter(mAdapterRelated);
});
vRelatedStub.inflate();发布于 2019-10-24 16:09:41
在我的代码中发现了错误。问题是,我要求在绑定的第一个项目的保证金,这仍然是从垂直线性管理器。
https://stackoverflow.com/questions/58528401
复制相似问题