android形状内的形状
问题描述:
我想要一个具有2色边框轮廓的elmenent。我可以使用这个元素做一个单独的颜色轮廓,但是这只允许我画一条线。我试过在我的内部使用2个元素,但这也没有奏效。有没有办法在一个形状中绘制一个形状,或者在我的形状周围绘制两条线(其中有圆角的btw)。android形状内的形状
感谢 本
答
我发现<layer-list>
是最好的办法。就像这样:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="6dip"
android:right="6dip">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="3dip"
android:color="#000000" />
</shape>
</item>
<item
android:bottom="1dip"
android:left="8dip"
android:right="8dip"
android:top="1dip">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="2dip"
android:bottomRightRadius="2dip"
android:topLeftRadius="2dip"
android:topRightRadius="2dip" />
<solid android:color="@android:color/white" />
<stroke
android:width="1dip"
android:color="#BDBDBD" />
</shape>
</item>
</layer-list>
然后你需要把适当的利润率您listView
排布置,但它的作品相当不错。
答
,所以我有一个解决办法,但它的丑陋。解决方法是将我的元素封装在另一个容器元素中。即
<RelativeLayout ... android:background="@drawable/outer"> <ListView ... android:background="@drawable/inner" /> </RelativeLayout>