android – 不同颜色的布局

前端之家收集整理的这篇文章主要介绍了android – 不同颜色的布局前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想要一个RelativeLayout的背景颜色与下面链接显示的图像类似.忽略图像下半部分的黑色条纹.

我不想使用图像作为布局的背景.你能给我一个如何进行的想法吗?

解决方法@H_502_6@
您可以使用渐变.根据需要在选择器中设置不同的渐变.完成!

GradientDrawable.class

这是你想要的,设置你的颜色.请享用!

<?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>

原文链接:https://www.f2er.com/android/309958.html

猜你在找的Android相关文章