<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" android:textColor="@color/all_black"
android:gravity="center_horizontal"/>
</LinearLayout>
复制代码
在 strings.xml 中创建两个颜色资源。
清单 2. strings.xml 中的颜色
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Android FlashLight</string>
<string name="app_name">FlashLight</string>
<color name="all_white">#FFFFFF</color>
<color name="all_black">#000000</color>
</resources>
复制代码
主屏幕布局有一个定义为 all_white 的背景色。在 strings.xml 文件中,可以看到 all_white 被定义为一个值为 #FFFFFF 的 RGB 三元组,即纯白。