如何创建此布局

时间:2018-11-25 14:43:07

标签: java android xml

我要创建此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);

0 个答案:

没有答案