3
我想製作一個自定義列表分隔線。它有一條水平線,這是一個微妙的漸變,第二條水平的白線就像是一種「陰影」。如何在Android xml中製作兩條平行和相鄰的線條?
我正在嘗試使用<layer-list>
來完成我想要的功能,但它沒有按照我期望的方式工作。
下面的代碼:
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:startColor="#ccd0d3"
android:centerColor="#b6babd"
android:endColor="#ccd0d3"
android:height="1px"
android:angle="0" />
</shape>
</item>
<item android:top="2px">
<shape
android:color="@android:color/white"
android:height="1px" />
</item>
</layer-list>
如果我使用android:divider
這個分配給ListView
並設置android:dividerHeight="2"
,我得到一個灰色漸變這兩個像素高。白線無處可見。
如果我設置白線的android:top="1px"
,我會看到一個像素的灰色漸變和它下面的一個像素黑線。
任何想法我做錯了什麼?