Android settings background color can be defined by an XML in Res/drawable, as follows:
<? xml version= "1.0" encoding= "Utf-8" ?> < shape xmlns:android = "Http://schemas.android.com/apk/res/android" > < gradient android:startcolor = "#FFF" Android:endcolor = "#000" Android:angle = "" /> </ shape >
Shape is used to define the shape, gradient defines the shape as a gradient fill, startcolor start color, EndColor end color, and angle represents the direction angle. When angle=0, the gradient color is left to right. Then turn counterclockwise, when angle=90 is from bottom to top.
implementation Process :
The first step:
Res/drawable/background_login.xml
<? XML version= "1.0" encoding= "Utf-8" ?> < xmlns:android= "http://schemas.android.com/apk/res/android"> <gradient android:startcolor= "#FFF" Android:endcolor = "#000" android:angle= "/>"</ Shape>
Step Two:
Res/layout/login.xml
<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"android:orientation= "vertical"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"Android:background= "@drawable/background_login"></LinearLayout>
Step Three:
Import android.app.Activity; Import Android.os.Bundle; Public class extends Activity { @Override publicvoid onCreate (Bundle savedinstancestate) { Super . OnCreate (savedinstancestate); Setcontentview (R.layout.login); }}
Android Background Fade color (shape,gradient)