一、资源目录
1./res/layout,存放布局文件
2./res/values,值文件
(1)根元素<resources.../>
根元素中的子元素代表不同资源
例: -string/integer/boolean 代表字符串值、整数值、布尔值
-color 颜色值
-dimen 添加尺寸
-array/string-array/int-array 添加数组
-style 添加样式或主题
(2)保存文件
arrays.xml定义数组资源
colors.xml定义颜色值资源
strings.xml定义字符串资源
styles.xml定义样式资源(style、theme)
dimens.xml定义尺寸资源
attrs.xml定义属性资源
3./res/drawable/,存放各种位图,或各种drawable对象的xml文件
4./res/xml/,原生xml文件
5./res/raw/,不懂
6./res/animator/,属性动画
7./res/anim,补间动画
二、使用资源(文件的主要部分)
1.字符串
<resources>
<string name="Hello">Hello world</string>
<string name="app_nmae">字符串、颜色、尺寸资源</string>
<string name="c1">#F00</string>
</resources>
2.颜色
<resources>
<color name="c1">#F00</color>
<color name="c2">#F0F</color>
<color name="c3">#00F</color>
</resources>
3.尺寸
<resources>
<dimen name="spacing">8dp</dimen>
<!--定义GridView组件中每个单元格的宽高-->
<dimen name="cell_width">60dp</dimen>
<dimen name="cell_height">66dp</dimen>
<!--定义主程序标题的字体大小-->
<dimen name="title_font_size">18sp</dimen>
</resources>
4.数组
(1)<array.../>
<string-array
<intyeger-array>
(2)
<resources>
<!--定义drawable数组-->
<array name="plain_array">
<item>@color/c1</item>
<item>@color/c2</item>
<item>@color/c3</item>
</array>
<!--定义字符串数组-->
<string-array name="string_array">
<item>@string/c1</item>
<item>@string/c2</item>
<item>@string/c3</item>
</string-array>
<!--定义字符串数组-->
<string-array name="string_array">
<item>科比</item>
<item>韦德</item>
<item>艾弗森</item>
</string-array>
</resources>
5.style
(1)样式
<resources>
<style name="style1">
<item name="android:textSize">20dp</item>
<item name="android:textColor">#0F0</item>
</style>
<style name="style2" parent="@style/style1">
<item name="android:background">#ee6</item>
<item name="android:padding">10dp</item>
<!--覆盖父样式中指定属性-->
<item name="android:textColor">#F00</item>
</style>
</resources>
(2)主题(theme)
6.drawable
7.属性(attribute)
8.原始xml
9.原始资源
10.国际化和资源自适应