我正在尝试为 DividerItemDecoration 设置我的自定义可绘制对象(线),但没有成功。哪里错了?
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(getContext(),
LinearLayoutManager.VERTICAL);
dividerItemDecoration.setDrawable(getContext().getResources().getDrawable(R.drawable.sk_line_divider));
XML 形状:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="1dp"
android:color="#000000">
</stroke>
</shape>
最佳答案
将形状改为矩形。
例如:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size
android:width="1dp"
android:height="1dp" />
<solid android:color="@color/primary" />
</shape>
关于android - 为 DividerItemDecoration 设置可绘制对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40528012/