Android Drawable自定义样式

1.Progress
< layer-list xmlns: android = "http://schemas.android.com/apk/res/android" >
    < item android :id= "@android:id/background" >
        < shape >
            < corners android :radius= "5dip" />
            < solid android :color= "@color/color_gray" />
        </ shape >
    </ item >
    < item android :id= "@android:id/progress" >
       < clip >
       < shape >
        < corners android :radius= "5dip" />
        < solid android :color= "@color/score_progress_one" />
       </ shape >
       </ clip >
    </ item >
</ layer-list >
设置进度条,背景色和进度条颜色,如 ProgressBar

2.View点击背景
<? xml version= "1.0" encoding= "utf-8" ?>
< selector xmlns: android = "http://schemas.android.com/apk/res/android" >
    < item android :state_pressed= "false" >
    < shape android :shape= "rectangle" >
        < solid android :color= "@color/item_gray_color_normal" />
    </ shape >
    </ item >
    < item android :state_pressed= "true" >
    < shape android :shape= "rectangle" >
        < solid android :color= "@color/item_gray_color_pressed" />
    </ shape >
    </ item >
</ selector >
设置矩形点击背景,如 LinearLayout Button

3.View选中背景
<? xml version= "1.0" encoding= "utf-8" ?>
< selector xmlns: android = "http://schemas.android.com/apk/res/android" >
    < item android :state_checked= "true"
        android :drawable= "@drawable/is_checked" /> <!--选中时效果-->
    < item android :state_checked= "false"
        android :drawable= "@drawable/not_checked" /> <!--未选中时效果-->
</ selector >
设置布局选中背景,如 RadioButton,CheckBox

4.View背景
<? xml version= "1.0" encoding= "utf-8" ?>
< shape xmlns: android = "http://schemas.android.com/apk/res/android" >
    < corners android :radius= "5dp" />
    < solid android :color= "@color/color_background" />
</ shape >
设置布局默认背景,圆角+填充色, 如 Dialog, LinearLayout

5.View背景
<? xml version= "1.0" encoding= "utf-8" ?>
< shape xmlns: android = "http://schemas.android.com/apk/res/android" >
    < corners android :bottomLeftRadius= "@dimen/offset_5dp" />
    < solid android :color= "@color/white" />
    < stroke android :width= "1dp"
        android :color= "@color/color_gray" />
</ shape >
设置布局背景,部分圆角+填充色+边线, 如 TextView, LinearLayout

6.Divider 分割线
<? xml version= "1.0" encoding= "utf-8" ?>
< shape xmlns: android = "http://schemas.android.com/apk/res/android"
    android :shape= "rectangle" >
    < size android :height= "0.5dp" />
    < solid android :color= "@color/color_gray" />
</ shape >
设置分割线,高度和颜色, 如 ListView














猜你喜欢

转载自blog.csdn.net/qq_42022061/article/details/80926715