Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Layout with different colors

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.

image 1

I don't want to use the image as a background of the layout. Can you give me an idea of how to proceed?

like image 766
curiousguy Avatar asked Feb 22 '12 11:02

curiousguy


3 Answers

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>
like image 184
SkyWalker Avatar answered Sep 21 '22 17:09

SkyWalker


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

like image 37
jyotiprakash Avatar answered Sep 24 '22 17:09

jyotiprakash


//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>
like image 29
Padma Kumar Avatar answered Sep 23 '22 17:09

Padma Kumar