5

<shape>我正在尝试在 android drawable xml 中的一个元素中的一个矩形上有效地实现 2 次笔划。一条深绿色的外线和一条浅绿色的内线,中间有一个渐变填充。我的代码目前如下所示:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">



<item>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">

        <stroke android:width="3px" android:color="#477135" />
    </shape>

</item>
<item >
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <gradient android:startColor="#81c557" android:endColor="#539942"
            android:angle="270" />

        <stroke android:width="1px" android:color="#a8d78a" />
    </shape>
</item>

我尝试将 android:top="3px" android:bottom="3px" 应用到第二个 item 元素,但是当我添加 right & left 属性时,整个东西都不会渲染。注意,这都是在 ListView 中完成的

4

1 回答 1

1

好吧,我相信我通过变通解决了这个问题。它不漂亮,但它有效。我所做的是将 ImageView 设置为背景颜色设置为外线颜色,给它一个 1dip 的填充,然后将 ImageView 的 src 设置为可绘制对象,我实现了我正在寻找的效果。也就是说,我更希望能够在图层列表中完成这一切......

于 2010-06-23T15:25:53.253 回答