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.

enter image description here

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:

enter image description here

see this article.


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -