Suzy
Suzy

Reputation: 99

Custom Background colors with different gradients

Actually, I want to apply this as a background for my Android App pages but I want to write it in XML and I don't know where should I start from ?enter image description here

Upvotes: 2

Views: 295

Answers (1)

Yasin Kaçmaz
Yasin Kaçmaz

Reputation: 6663

Actually you know how to do it. Gradient, GradientDrawable is the key.

Good to read this huge drawable tutorial/source : Drawables. For Gradient search this header : Gradient Colored Shapes

Also shorter one : gradient-drawable-in-android.

Also if you want to do it thru styles.xml just add this line to your Theme. It will add background.xml to all your activities by default.

<item name="android:windowBackground">@drawable/background</item>

Don't forget you can set simple colors too like that :

<item name="android:windowBackground">#AA123456</item>

If you want to change Activity background color, background drawable programmatically, I am using this way :

//for color
getWindow().getDecorView().setBackgroundColor(yourdesiredcolor);
//for drawable,eg gradient
getWindow().getDecorView().setBackground(yourdesireddrawable);

Upvotes: 1

Related Questions