Reputation: 894
I am trying to create a border with round corners on transparent button like this:
here is my 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>
Upvotes: 16
Views: 17488
Reputation: 469
enter image description here This is way to answer your question:
<?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="@color/white" />
<solid android:color="@android:color/transparent" />
<corners android:radius="4dp" />
</shape>
</item>
</selector>
Another easy way is just to use shape instead of selector, and put this code in shape:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="1dp" android:color="@color/white" />
<solid android:color="@android:color/transparent" />
<corners android:radius="4dp" />
</shape>
Upvotes: 1
Reputation: 1048
Try this
<?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>
Upvotes: 31