【问题标题】:Rectangle inside another rectangle另一个矩形内的矩形
【发布时间】:2011-11-24 08:07:29
【问题描述】:

是否可以像图片一样从 xml 创建可绘制对象?第一个矩形包含第二个矩形。

如果是,请告诉我怎么做。

【问题讨论】:

  • 您想通过将矩形放在矩形内来做什么,您是否想执行一些其他的显示此操作...

标签: android xml-drawable


【解决方案1】:

如果你想要简单的矩形,你可以使用 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>

【讨论】:

  • 我知道层列表。非常感谢!
  • 你知道阴影效果是如何使用可绘制形状的吗?
  • 非常感谢 :) @Luksprog
猜你喜欢
  • 2011-10-18
  • 2020-07-31
  • 1970-01-01
  • 2014-12-20
  • 2018-12-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多