Android基础:res目录

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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值