我要创建此layout,年份数据将来自服务器。 我尝试使用RecyclerView的交错布局管理器,因为服务器将发送任意数量的年数,但无法正常工作。我得到this
选择years.xml
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview_years"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
/>
SelectingyearsActivity.java
StaggeredRecyclerviewAdapter adapter = new StaggeredRecyclerviewAdapter(arrayList);
StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(3,
LinearLayoutManager.VERTICAL);
recyclerview_years.setLayoutManager(staggeredGridLayoutManager);
recyclerview_years.setAdapter(adapter);