1

我想在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. 最新的_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.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>
4

0 回答 0