您的位置:首页 > 编程语言

安卓自定义控件背景颜色设置代码.xml文件

2016-01-20 15:37 337 查看
list_selector.xml文件:

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Selector style for listrow -->

    <item android:drawable="@drawable/gradient_bg" android:state_pressed="false" android:state_selected="false"/>

    <item android:drawable="@drawable/gradient_bg_hover" android:state_pressed="true"/>

    <item android:drawable="@drawable/gradient_bg_hover" android:state_pressed="false" android:state_selected="true"/>

</selector>

gradient_bg.xml文件:

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android"

    android:shape="rectangle">

  <!--  Gradient Bg for listrow -->

  <gradient

      android:startColor="#f1f1f2"

      android:centerColor="#e7e7e8"

      android:endColor="#cfcfcf"

      android:angle="90" />

</shape>

gradient_bg_hover.xml文件:

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android"

    android:shape="rectangle">

  <!-- Gradient BgColor for listrow Selected -->

  <gradient

      android:startColor="#18d7e5"

      android:centerColor="#16cedb"

      android:endColor="#09adb9"

      android:angle="270" />

</shape>

给图片控件后面加一个长方形背景效果图image_bg.xml:

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item>

      <shape 

        android:shape="rectangle">

            <stroke android:width="1dp" android:color="#dbdbdc" />

            <solid android:color="#FFFFFF" />

        </shape>

   </item>

</layer-list>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  xml