Reputation: 1315
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.
Upvotes: 3
Views: 4205
Reputation: 2258
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);
Upvotes: 1
Reputation: 1644
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.
Upvotes: 0
Reputation: 1597
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>
Upvotes: 6