How can I make the ripple effect look like a circle instead of an oval?

3k views Asked by At

I have the same ripple effect on most of my image buttons and on most of them it looks like a circle when pressed but on some buttons it looks like an oval and I'm just not sure why it looks different. I realize the actual ripple shape is set as oval but why does it look like a circle on some other buttons. It could be that I am just not seeing it right since it happens so quickly.

Here is my ripple xml:

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="?android:colorControlHighlight">
    <item android:id="@android:id/mask">
        <shape android:shape="oval">
            <solid android:color="?android:colorPrimary" />
        </shape>
    </item>
</ripple>

Thanks.

EDIT: Turned out to be an issue with me using layout_weight on the ImageButtons inside a LinearLayout. I removed the weight from the individual buttons and instead added spaces with a weight of one between each button like this:

 <Space
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="1" />
1

There are 1 answers

4
yoga murthy On BEST ANSWER

Yes . I too had the same issues. The effect is purely dependent on the dimension of the object. for eg a 512*512 image gave me perfect circled ripple effect and a rectangular button on the bottom of the screen gave me oval/ellipsed effect. so i added a small square button behind that rectangular button and added effect to that squared button. when that button is pressed i call that square button to show up the effect.