recycleview 自定义分割线
DividerItemDecoration divider = new DividerItemDecoration(getActivity(),DividerItemDecoration.VERTICAL); divider.setDrawable(ContextCompat.getDrawable(getActivity(),R.drawable.custom_divider)); mRvSort.addItemDecoration(divider); 其中custom_divider 是: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="@color/decolratiion" android:centerColor="@color/decolratiion" android:endColor="@color/decolratiion" android:type="linear" /> <size android:height="1dp" /> </shape>
这样在shape文件中定义你的分割线的样式,变色的,不变的。都行