Android自定义Button背景色,弧度

Android自定义Button背景色,弧度

作为selector放在drawable中

  • android:state_pressed=”true” 点击
  • android:state_focused=”true” 聚焦

自定义的Button的xml文件(res/drawable/button_selector.xml)


<selector
    xmlns:android="http://schemas.android.com/apk/res/android">
    
    <item android:state_pressed="true" >
        <shape  android:shape="rectangle">
            <gradient
                android:startColor="#ff8c00"
                android:endColor="#ff8c00"
                android:angle="270" />           
            <corners
                android:radius="4dp" />
        shape>
    item>
   
   <item android:state_focused="true" >
        <shape>
            <gradient
                android:startColor="#ffc2b7"
                android:endColor="#ffc2b7"
                android:angle="270" />            
            <corners
                android:radius="4dp" />
        shape>
    item>

    <item>        
        <shape>
            <gradient
                android:startColor="#d0d0d0"
                android:endColor="#d0d0d0"
                android:angle="0" />
            <corners
                android:radius="4dp" />
        shape>
    item>
selector>

引用

"wrap_content"
    android:layout_height="wrap_content"
    android:paddingRight="10dip"
    android:paddingTop="3dip">
    "@+id/time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:textColor="@color/light_grey" />
    

Android自定义Button背景色,弧度_第1张图片

你可能感兴趣的:(Android组件UI)