【问题标题】:Android multiple stroke box in drawable xml可绘制xml中的Android多笔画框
【发布时间】:2010-06-23 00:30:13
【问题描述】:

我正在尝试在 android 可绘制 xml 中的 <shape> 元素中的矩形上有效地实现 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 中完成的

【问题讨论】:

    标签: xml android shape drawable stroke


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-28
      • 1970-01-01
      • 2014-07-06
      • 2014-09-02
      相关资源
      最近更新 更多