res目录下可以创建文件夹:color + drawable + anim
selector可以都放在drawable目录中。
color:里面是selector(正常的颜色和按下的颜色)
drawable:里面是selector(正常的图片和按下的图片)
anim:里面是动画
1 color目录
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="true" android:color="#ff0000"></item>
<item android:color="#000000"></item>
</selector>
2 drawable目录
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/home_press2" android:state_pressed="true"></item>
<item android:drawable="@drawable/home_press2" android:state_checked="true"></item>
<item android:drawable="@drawable/home2"></item>
</selector>
3 anim目录:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:fromXDelta="-100%"
android:fromYDelta="0"
android:toXDelta="0"
android:toYDelta="0" >
<!-- 原点 到1倍 500 -->
</translate>
values目录下可以创建XML文件 attrs.xml + colors.xml + dimens.xml + drawables.xml + ids.xml(都加s)
attrs.xml:自定义属性(参考:http://blog.csdn.net/ss1168805219/article/details/51225952)
colors.xml:颜色
dimens.xml :数值
drwaables.xml:颜色
ids.xml:自定义id
1 attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- declare-styleable申明控件属性的标签 -->
<!-- name 控件名 -->
<declare-styleable name="SettingItemView">
<attr name="title" format="reference|string" />
<attr name="desc_on" format="reference|string" />
<attr name="desc_off" format="reference|string" />
<attr name="check" format="boolean" />
</declare-styleable>
<!-- name属性名 format类型 text="文本" text="@string/"-->
</resources>
2 colors.xml
<resources>
<color name="white">#FFFFFF</color>
<color name="black">#000000</color>
<color name="red">#E51A18</color>
<color name="line_color">#523E2E</color>
</resources>
3 dimens.xml
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
4 drawables.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="transparent" type="drawable">#00000000</item>
<item name="red" type="drawable">#00000000</item>
<item name="white" type="drawable">#ffffffff</item>
<item name="yellow" type="drawable">#ffff9000</item>
<item name="green" type="drawable">#ff40929C</item>
<item name="black" type="drawable">#000000</item>
</resources>
5 ids.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="list_view" />
</resources>