Issue
I'm trying to create a segmented buttons control and I've used a single drawable for each of the segments.
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="@color/search_filters_selected" />
</shape>
</item>
<item>
<shape
android:padding="10dp"
android:shape="rectangle">
<solid android:color="@color/search_filters_unselected" />
<stroke
android:width="1dp"
android:color="@color/search_filters_selected" />
</shape>
</item>
</ripple>
Then, according to whether it's the first, last or in the middle, I set the corner radius to have rounded left corners, right corners or none, using setCornerRadii
.
The problem is that I'm trying to show a ripple effect in the view, and I can't make it so that the ripple effect is bounded by the rounded corners, it's always drawn up to the original rectangle, like this
I've tried setting the same corner radii to the mask of the RippleDrawable, or using
<item android:drawable="?android:selectableItemBackground" />
within a layer-list instead of a <ripple>
, but the result is the same. Does anyone know how to make it so the ripple is bounded up to the new bounds?
Solution
The solution, if it's useful for anyone, it's to use a ripple without mask, but also with a set corner radius (any one, it will be updated later)
So I used
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<item>
<shape android:shape="rectangle">
<solid android:color="#625505" />
<corners android:radius="1dp"/>
</shape>
</item>
<item>
<shape
android:padding="10dp"
android:shape="rectangle">
<solid android:color="@color/search_filters_selected" />
<stroke
android:width="1dp"
android:color="@color/search_filters_selected" />
</shape>
</item>
</ripple>
and finally got it to work
Answered By - Koitt
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.