Layout with different colors

前端 未结 3 614
情书的邮戳
情书的邮戳 2021-02-06 02:07

I\'d like to have a background color of a RelativeLayout similar to that of an image shown in the link below. Ignore the black strip in the bottom half of the image

相关标签:
3条回答
  • 2021-02-06 02:50

    You can use gradient. Set different gradient in selector as you want. Done!

    GradientDrawable.class

    This is what you want, set your colors. Enjoy!

    <?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>
    
    0 讨论(0)
  • 2021-02-06 02:52

    //save this below code as gradient and use as background of your layout as

    android:background="@drawable/gradient"
    

    //gradient.xml

    <?xml version="1.0" encoding="UTF-8"?> 
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <gradient android:startColor="#232323" android:endColor="#4B5059"
            android:angle="270"/>
    </shape>
    
    0 讨论(0)
  • 2021-02-06 02:59

    just try with shape file structure. I think this may give the solution.

    0 讨论(0)
提交回复
热议问题