3

I want to know if this kind of gradient color is possible in android? If possible then how? http://www.techandall.com/wp-content/uploads/2013/10/techandall_mobile-analytics-UI-concept_preview1.jpg

Thanks, Bskania.

3 Answers 3

6

Here you have an online tool for creating gradient shapes for android:

http://angrytools.com/gradient/

By clicking on the android tab, you get xml with shape(s) :

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<gradient 
    android:type="linear"
    android:centerX="47%" 
    android:startColor="#FF70C1FF" 
    android:centerColor="#FFBDC9FF" 
    android:endColor="#FF734080" 
    android:angle="45"/>
</shape>

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<gradient 
    android:type="radial"
    android:centerX="50%" 
    android:centerY="50%" 
    android:startColor="#FF70C1FF" 
    android:centerColor="#FFBDC9FF" 
    android:endColor="#FF734080" 
    android:gradientRadius="47"/>
</shape>
Sign up to request clarification or add additional context in comments.

1 Comment

actually its giving linear gradient color shape but as you can see in image its not exactly the linear gradient. if you select two colors than it should go top to bottom with each color light to dark shade side by side.
1
int startColor=Color.parseColor("#a6c1de");
//you can add as many gradient colors as you want here
//and include it in the int array while initializing GradientDrawable 
int endColor=Color.parseColor("#aa82b7");
GradientDrawable mDrawable=new GradientDrawable(Orientation.LEFT_RIGHT,
                                    new int[] {startColor,endColor});

LinearLayout mLayout=(LinearLayout)findViewById(R.id.your_id);
mLayout.setBackgroundDrawable(mDrawable);

1 Comment

Yes but you can add another color at the center. new int[] startColor,centerColor, endColor}
0

You can't create Gradient using many colors like in your image where two colors goes linear. So You should use Image instead of gradient.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.