简体   繁体   English

DividerItemDecoration 不显示android

[英]DividerItemDecoration not showing up android

I have this simple layout for recycler view items.我有这个简单的回收站视图项目布局。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/details"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:background="?android:attr/selectableItemBackground"
android:paddingEnd="15dp"
android:paddingStart="15dp"
>

<org.tchouaffe.ftinfosystem.utils.CustomTextView
    android:id="@+id/name"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:gravity="center_vertical"
    android:textColor="@color/primaryTextColor"
    android:textSize="15sp"/>


<org.tchouaffe.ftinfosystem.utils.CustomTextView
    android:id="@+id/level"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentRight="true"
    android:layout_toRightOf="@id/name"
    android:gravity="center_vertical|right"
    android:textColor="@color/primaryTextColor"
    android:textSize="15sp"/>
</RelativeLayout>

You also need to call setDrawable() on DividerDecoration . 您还需要调用setDrawable()DividerDecoration

Provide a drawable resource. 提供可绘制的资源。 An XML shape drawable can be a good start. XML形状drawable可以是一个好的开始。 The shape will be rendered as the divider between recycler item views. 形状将呈现为回收器项视图之间的分隔符。

Alternatively, when declaring the app theme, you can set android:listDivider item to the desired drawable. 或者,在声明应用主题时,您可以将android:listDivider项设置为所需的drawable。

try using this vector as divider line尝试使用这个向量作为分隔线

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="2dp"
android:viewportWidth="24"
android:viewportHeight="2">
<path
    android:pathData="M0,0L100,0.5"
    android:strokeWidth="2"
    android:fillColor="#00000000"
    android:strokeColor="@color/lessons_divider_line_background"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM