我有这个代码:
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cashItemsList"
android:cacheColorHint="#00000000"
android:divider="@drawable/list_divider"></ListView>
Run Code Online (Sandbox Code Playgroud)
在哪里@drawable/list_divider:
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="1dp"
android:color="#8F8F8F"
android:dashWidth="1dp"
android:dashGap="1dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)
但我看不到任何分隔线.
我有一个渐变的形状,我用它作为ListView物品之间的分隔物.我把它定义如下:
<?xml version="1.0" encoding="UTF-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#ccd0d3"
android:centerColor="#b6babd"
android:endColor="#ccd0d3"
android:height="1px"
android:angle="0" />
</shape>
Run Code Online (Sandbox Code Playgroud)
我想在渐变的两侧添加6个像素的填充,这样它就不会从屏幕的边缘延伸到边缘.
但是,无论身在何处,我把一个android:left="6px"和android:right="6px",它似乎并没有生效.我可以把它放在<shape>元素,<gradient>元素或者单独的<padding>子元素中,<shape>它不会改变任何东西.
如何在列表分隔符的左侧和右侧添加填充?