Я хочу встановити різні розмітки стовпців для рядка, як я показую на малюнку нижче
Я хочу, щоб цей тип компонування в даний час я отримую два зображення для використання recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
на кожному рядку так, як я можу цього досягти.
RecycleView макет елемента, як
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.gordonwong.materialsheetfab.sample.SquareImageView
android:id="@+id/phone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
і в моєму класі клас набір адаптерів, як
recyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_view);
adapter = new GridViewAdapter(getActivity(), infoarraylist);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
Collections.reverse(infoarraylist);
recyclerView.setItemAnimator(new DefaultItemAnimator());
Відповіді:
-1 для відповіді № 1mLayoutManager = new GridLayoutManager(getActivity(), 2);
mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (infoarraylist.get(position) instanceof YOUROBJECT) {
return 1;
} else if (infoarraylist.get(position) instanceof YOUROBJECT) {
return 2;
}
return -1;
}
});
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setAdapter(adapter);