【发布时间】:2011-11-24 08:07:29
【问题描述】:
是否可以像图片一样从 xml 创建可绘制对象?第一个矩形包含第二个矩形。
如果是,请告诉我怎么做。
【问题讨论】:
-
您想通过将矩形放在矩形内来做什么,您是否想执行一些其他的显示此操作...
标签: android xml-drawable
是否可以像图片一样从 xml 创建可绘制对象?第一个矩形包含第二个矩形。
如果是,请告诉我怎么做。
【问题讨论】:
标签: android xml-drawable
如果你想要简单的矩形,你可以使用 LayerList 两个形状作为内容:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#a1a1a1" />
</shape>
</item>
<item android:top="5dp" android:right="5dp" android:bottom="5dp"
android:left="5dp">
<shape android:shape="rectangle">
<solid android:color="#f1f1f1" />
</shape>
</item>
</layer-list>
【讨论】: