如何在Android RecyclerView中添加分隔线? [英] How can a divider line be added in an Android RecyclerView?
本文介绍了如何在Android RecyclerView中添加分隔线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用RecyclerView
开发一个android应用程序.我需要在RecyclerView
中添加一个除法器.
我尝试添加-
I am developing an android application where I am using RecyclerView
. I need to add a divider in RecyclerView
.
I tried to add -
recyclerView.addItemDecoration(new
DividerItemDecoration(getActivity(),
DividerItemDecoration.VERTICAL_LIST));
下面是我的xml代码-
below is my xml code -
<android.support.v7.widget.RecyclerView
android:id="@+id/drawerList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
/>
推荐答案
在2016年10月的更新中,支持库v25.0.0现在具有默认的基本水平和垂直分隔线实现!
In the October 2016 update, the support library v25.0.0 now has a default implementation of basic horizontal and vertical dividers available!
https://developer.android.com/reference/android/support/v7/widget/DividerItemDecoration.html
recyclerView.addItemDecoration(new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL));
这篇关于如何在Android RecyclerView中添加分隔线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文