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. 

from

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="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com.tools"
        android:background="@color/black"
        android:layout_width="match_parent" 
        android:layout_height="match_parent"   >
 
       </RelativeLayout>

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:

android:background="#ff0000ff“

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

android:background="#ff00ff00“

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"?>
<resources>
<color name="blue">#ff0000ff</color>
</resources>

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. :

android:background="@color/blue“

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.

<TextView
android:id="@+id/myTextViewy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textColor="@color/blue"
android:text=“text blue color" />

Source: Master Android (App)

Post Author: Study