Android Resource Introduction of Color (Color)

Color Resource Android (Google Images Images)

One of the most effective ways to make your Android application stand out is to add some color. 


Create a new Android project and delete the default UI layout elements and the resulting Eclipse. To begin, we will do this project to change the background to black.

<RelativeLayout xmlns:android=""
        android:layout_height="match_parent"   >

constant Color

 You must use a constant color, if you want to add more color.

At the most basic level, changing the background color is simply a matter of replacing “@ color / black” with one of these codes. For example, the value for the ‘blue’ is:

Value Constants: -16776961 ff0000ff

Enter the following to change the background (Background) to blue:


Or, to change the background color (Background) green to enter:


Color.xml file has been added to the folder ‘Values’.

1. Open the file color.xml and switch to the tab ‘color.xml’ if it does not open automatically.

2. Enter the following:

<?xml version="1.0" encoding="utf-8"?>
<color name="blue">#ff0000ff</color>

3. Return to the XML file res / layout and set the background color, in exactly the same way as ‘black’ which we have used before. :


4.Beralih to the graphical layout editor. The background should now be blue.

Try to change the background color to determine the last time a new color:

<color name="LightPink">#FFE4E1</color>

Back to the layout file and replace the “@ color / blue” with “@ color / lightpink.” 

Applying color to the UI elements (Layout)

Once you define your colors, one line of XML is all that is required to change the color of text / button / EditText or widget you choose ..

This example we will use TextViews:

Here we are going to do !! Just add this line to the text color of the widget anywhere.

android:text=“text blue color" />

Source: Master Android (App)

Post Author: Study