Android Background Fade color (shape,gradient)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.