边框周围透明按钮

时间:2016-01-16 15:01:01

标签: android android-layout android-fragments android-activity

我正在尝试在透明按钮上创建一个带圆角的边框,如下所示:

enter image description here

这是我的transparent.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/blue" android:state_pressed="true"/>
<item android:drawable="@android:color/transparent"/>  
</selector>

1 个答案:

答案 0 :(得分:23)

试试这个

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item><shape>
            <stroke android:width="1dp" android:color="#000000" />

            <solid android:color="@android:color/transparent" />

            <corners 
                android:bottomLeftRadius="4dp" 
                android:bottomRightRadius="4dp" 
                android:topLeftRadius="4dp" 
                android:topRightRadius="4dp" />
        </shape></item>

</selector>