android capsule shaped drawable with selectableItemBackground as background -
i have couple buttons need oval shaped border.
so have in capsule_border.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="9999dp"/> <stroke android:width="1px" android:color="@color/border_gray" /> </shape> and use android:background="@drawable/capsule_border.xml need it.
now, have button have oval shaped border, android:background="?selectableitembackground" visual feedback.
i tried use parent layout selectableitembackground , button capsule_border. seems clickable area gets highlighted whole square. instead of area within capsule border.
is there someway can make selectableitembackground not highly whole rectangle of view, within border draw?
having round_corners.xml:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@android:color/transparent"/> <corners android:radius="15dp" /> <stroke android:width="1px" android:color="#000000" /> </shape> and my_ripple.xml:
<?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:attr/colorcontrolhighlight"> <item android:id="@android:id/mask"> <shape android:shape="rectangle"> <solid android:color="#000000" /> <corners android:radius="15dp" /> </shape> </item> <item android:drawable="@drawable/rounded_corners" /> </ripple> and button:
<button android:background="@drawable/selector" ... /> will result in this:
see this article.


Comments
Post a Comment