bubblebath
bubblebath

Reputation: 999

Have a two tone effect colour in an android background

I want to know if it is possible to have a background colour for a textview that is two toned. For example if I can specify left as black and right as white and the in-between would fill effectually black to dark grey to grey to light grey to white.

Upvotes: 0

Views: 333

Answers (1)

Budius
Budius

Reputation: 39836

yes, it's possible, that's called a Gradient.

simple example:

gradient_background.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
    <gradient 
        android:startColor="#6586F0"
        android:endColor="#4B6CD6"
        android:angle="90"/>
</shape>

then just set the view background to R.drawable.gradient_background

Upvotes: 1

Related Questions