在java或android程序中,用到颜色信息的时候,一般并不直接给定颜色信息而是用字符串来表示,
比如我们通常用下面的语句来设置布局的背景颜色
android:background="@drawable/white"
一般不直接使用android:background="#FFFFFF"
activity_main.xml中的设定 :
android:background="@drawable/darkgray"
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/darkgray"
tools:context=".MainActivity" >
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<drawable name="darkgray">#808080</drawable>
<drawable name="white">#FFFFFF</drawable>
<drawable name="blue">#0000FF</drawable>
<drawable name="lightred">#90FF0000</drawable>
<drawable name="lightgray">#90505050</drawable>
<string name="app_name">2writeio</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="SD">DS卡</string>
<string name="RAM">RAM内存</string>
</resources>