如何使用android中的图层列表设计Button

时间:2012-10-04 09:29:04

标签: android button drawable

我想设计android下面的按钮。我使用shape drawable来设计它。

http://i48.tinypic.com/9gh7ye.png

我几乎设计了这个,但是不能在按钮上找到寄宿生。(每个按钮上面的寄宿生)。

你可以看到每个按钮顶部都有黑暗的边框。 如何设计这个。我听说过layerlist但不知道如何使用它?

任何人都可以知道吗?请分享您的想法。谢谢。

最新的按钮xml - >

 <Button
        android:id="@+id/buttonRefresh"
        android:layout_width="@dimen/titlebar_refresh_button_width"
        android:layout_height="@dimen/titlebar_button_height"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:background="@drawable/refresh_btn_state_list_drawable"
        android:drawableLeft="@drawable/refresh"
        android:paddingLeft="14dp" />
  1. newest_btn_state_list_drawable.xml

    <item android:drawable="@drawable/newest_btn_shape_drawable_h" android:state_pressed="true"/>
    <!-- pressed -->
    <item android:drawable="@drawable/newest_btn_shape_drawable_f" android:state_selected="true"/>
    <!-- focused -->
    <item android:drawable="@drawable/newest_btn_shape_drawable"/>
    <!-- default -->
    

  2. 2.newest_btn_shape_drawable.xml

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle" >
    
        <gradient
            android:angle="45"
            android:endColor="#6080A8"
            android:startColor="#6080A8" />
    
        <padding
            android:bottom="5dp"
            android:left="5dp"
            android:right="5dp"
            android:top="5dp" />
    
        <corners
            android:bottomLeftRadius="5dp"
            android:bottomRightRadius="0dp"
            android:topLeftRadius="5dp"
            android:topRightRadius="0dp" />
    
        <stroke
            android:width="0.2dip"
            android:color="#000000" >
        </stroke>
    
    </shape>
    

    3.newest_btn_shape_drawable_h.xml

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle" >
    
        <gradient
            android:angle="45"
            android:endColor="#405070"
            android:startColor="#405070" />
    
        <padding
            android:bottom="5dp"
            android:left="5dp"
            android:right="5dp"
            android:top="5dp" />
    
        <corners
            android:bottomLeftRadius="5dp"
            android:bottomRightRadius="0dp"
            android:topLeftRadius="5dp"
            android:topRightRadius="0dp" />
    
        <stroke
            android:width="1dip"
            android:color="#000000" >
        </stroke>
    
    </shape>
    

    4.newest_btn_shape_drawable_h.xml

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle" >
    
        <gradient
            android:angle="45"
            android:endColor="#405070"
            android:startColor="#405070" />
    
        <padding
            android:bottom="5dp"
            android:left="5dp"
            android:right="5dp"
            android:top="5dp" />
    
        <corners
            android:bottomLeftRadius="5dp"
            android:bottomRightRadius="0dp"
            android:topLeftRadius="5dp"
            android:topRightRadius="0dp" />
    
        <stroke
            android:width="1dip"
            android:color="#000000" >
        </stroke>
    
    </shape>
    

0 个答案:

没有答案