Android多笔画框中的可绘制xml

Ben*_*Ben 5 xml android shape drawable stroke

我试图<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>
Run Code Online (Sandbox Code Playgroud)

我尝试将android:top ="3px"android:bottom ="3px"应用到第二个项目元素,但是当我添加右侧和左侧属性时,整个事物都不会渲染.注意,这都是在ListView中完成的

Ben*_*Ben 1

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