Search code examples
javaandroidimageviewscalingforeground

Zoomable RoundImageView - RoundImageView is still rectangle


I am trying to make zoomable RoundImageView. I am using this TouchImageView but I extend it with RoundedImageView not with standard ImageView. This TouchImageView is in some FrameLayouts which have these these backround:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#FFF"/>

This background also have TouchImageView. When I call on it function setOval(true) everything seems fine, until I start zooming. It's look like it only create rounded bitmap, but ImageView is still rectangle...

PS: I need to have oval not circle.

There are some images:

Before zooming:

After zooming:

Thank you for every answer! ;)


Solution

  • For thoose who have the same issue. I find MaskableFrameLayout which is pretty easy to use. It extends FrameLayout so it's possible to have zoomable view in it. Just create oval or your shape in drawable:

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid android:color="#FFFFFF"/></shape>
    

    and use setMask(drawable). Also you need to setPorterDuffXferMode(...). I used DST_IN.

    Hope it helps!