1.字符串资源
字符串资源定义在strings.xml文件中。
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">TestAMap</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="menu_navi">navi</string>
</resources>
2.颜色资源定义在colors.xml文件中。
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="gray">#BEBEBE</color>
<color name="green">#87CEEB</color>
</resources>
3.尺寸资源定义在dimens.xml文件中
<resources>
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="is_big">true</bool>
<bool name="is_small">false</bool>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="num1">1</integer>
<integer name="num2">2</integer>
</resources>
在android系统中使用这些资源分为在XML文件中使用和在java程序中使用。在XML文件中使用的时候,直接通过
@string/item,@color/item,@dimen/item等等直接使用。而在java程序中使用的时候通过获取resource,res.getString(),res,getColor()等方法获取值。