我想要 RelativeLayout
的背景颜色类似于下面链接中显示的图像的背景颜色。忽略图像下半部分的黑色 strip 。
我不想将图像用作布局的背景。你能告诉我如何进行吗?
最佳答案
您可以使用渐变。根据需要在选择器中设置不同的渐变。完成!
这就是你想要的,设置你的颜色。享受吧!
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:bottom="30dp">
<shape android:shape="rectangle" >
<corners
android:topRightRadius="8dip"
android:topLeftRadius="8dip" />
<gradient
android:startColor="#030303"
android:endColor="#3B3B3B"
android:angle="270" />
</shape>
</item>
<item android:top="30dp" >
<shape android:shape="rectangle" >
<corners
android:bottomLeftRadius="8dip"
android:bottomRightRadius="8dip" />
<gradient
android:startColor="#4B5057"
android:endColor="#4B5059"
android:angle="270" />
<size android:height="30dp" />
</shape>
</item>
</layer-list>
关于android - 不同颜色的布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9393776/