Reference color resource in TextView

Description

The following code shows how to Reference color resource in TextView

Example

res/values/colors.xml


<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="background_color">#aa0000</color>
</resources>

Layout xml


<?xml version="1.0" encoding="utf-8"?>

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/background_color"
    android:gravity="center"
    android:text="Hello World, MainActivity!" />

Reference color resource in TextView




















Home »
  Android »
    Android UI »




UI Basics
Action Bar
Animation
Button
Canvas
CheckBox
Clock Date Picker
Dialog
EditText
Event
Fragment
Gesture
GridView
ImageView
Layout
ListView
Map
Menu
Model
OpenGL
ProgressBar
RadioButton
Spinner
Tab
TextView
Thread
Toast
Video
View
WebView