Android:生成具有指定颜色底部的背景形状
Posted
技术标签:
【中文标题】Android:生成具有指定颜色底部的背景形状【英文标题】:Android: Generate Background shape with specified color bottom 【发布时间】:2015-02-21 17:45:15 【问题描述】:我想生成灰色的背景可绘制形状,底部为 2dp 厚和黑色。
我已经尝试了以下
<?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="#D3D3D3" />
</shape>
</item>
<item android:bottom="2dp" >
<shape android:shape="rectangle">
<solid android:color="#000000" />
</shape>
</item>
</layer-list>
但无法生成所需的形状。怎么办?
【问题讨论】:
【参考方案1】:如果你切换 2 种颜色,它应该可以工作。
<?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="#000000" />
</shape>
</item>
<item android:bottom="2dp" >
<shape android:shape="rectangle">
<solid android:color="#D3D3D3" />
</shape>
</item>
</layer-list>
【讨论】:
以上是关于Android:生成具有指定颜色底部的背景形状的主要内容,如果未能解决你的问题,请参考以下文章