开发中颜色、样式、数组等等的一些简单定义
Button按下后改变背景:
<?xml version="1.0" encoding="utf-8" ?> - <selector xmlns:android="http://schemas.android.com/apk/res/android">- <!-- 初始状态 --> <item android:state_pressed="false" android:drawable="@drawable/back_to_previous" /> - <!-- 按下状态 --> <item android:state_pressed="true" android:drawable="@drawable/back_to_previous_press" /> </selector>
定义圆角背景:
<?xml version="1.0" encoding="UTF-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#ffffffff" android:endColor="#ffffffff" android:angle="0.0" /> <corners android:topLeftRadius="10.0dip" android:topRightRadius="10.0dip" android:bottomLeftRadius="10.0dip" android:bottomRightRadius="10.0dip" /></shape>
颜色的定义 :
res\values\color.xml
<?xml version="1.0" encoding="utf-8" ?> - <resources> <drawable name="red">#D10A27</drawable> <drawable name="white">#FFFFFF</drawable> <drawable name="gray">#eff0f3</drawable> <color name="lightgray">#EAEAEA</color> <color name="borderColor">#ABABAB</color> <color name="no_back">#00000000</color> </resources>
一些控件样式的定义: res\values\styles.xml
<?xml version="1.0" encoding="UTF-8" ?> - <resources>- <!-- 动画 --> - <style name="AnimationPreview"> <item name="android:windowEnterAnimation">@anim/push_up_in</item> <item name="android:windowExitAnimation">@anim/slide_down_out</item> </style>- <!-- 主要的TabActivity --> - <style name="main_tab_bottom_sys"> <item name="android:textSize">@dimen/bottom_tab_font_size</item> <item name="android:textColor">#ffffffff</item> <item name="android:ellipsize">marquee</item> <item name="android:gravity">center_horizontal</item> <item name="android:paddingTop">@dimen/bottom_tab_padding_up</item> <item name="android:paddingLeft">3dip</item> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:button">@null</item> <item name="android:singleLine">true</item> <item name="android:drawablePadding">@dimen/bottom_tab_padding_drawable</item> <item name="android:layout_weight">1.0</item> </style> </resources>
自定义一个dimens.xml文件,里面存放一些属性,放在values文件夹下,方便修改:
res\values\dimens.xml
<?xml version="1.0" encoding="UTF-8" ?> - <resources> <dimen name="button_height">45.0dip</dimen> <dimen name="bottom_tab_font_size">9.0dip</dimen> <dimen name="bottom_tab_padding_up">32.0dip</dimen> <dimen name="bottom_tab_padding_drawable">2.0dip</dimen> <dimen name="switch_logo_bottom_padding">30.0sp</dimen> <dimen name="widget_height">100.0dip</dimen> <dimen name="sta_height">48.0dip</dimen> <dimen name="widget_write_margin_top">19.0dip</dimen> <dimen name="widget_write_margin_left">10.0dip</dimen> </resources>
自定义一个arrays.xml文件,放在values文件夹下,用来存放一些数组,方便使用时候取得;
<?xml version="1.0" encoding="UTF-8"?><resources><string-array name="main_munu_name"> <item>机票查询</item> <item>酒店查询</item> <item>航班动态</item> <item>酒店点评</item> <item>登录注册</item> <item>我的携程</item> <item>收藏夹</item> <item>问题反馈</item> <item>设置</item> </string-array></resources>
工程中出现的所有String类型的汉字都放在strings.xml下面,方便修改:
<?xml version="1.0" encoding="UTF-8"?><resources><string name="app_name">携程无线</string> <string name="app_name_en">Ctrip</string> <string name="system_init">系统初始化...</string> <string name="title_notice">最新公告</string> <string name="title_order">填写订单</string> <string name="filght_inquire">机票查询</string> <string name="title_filght_list">选择航班</string> <string name="title_filght_detail">航班详情</string></resources>