0

In android, I want to have a view with a round frame, so I could place another view inside it and get a masked effect.

Current situation:

blue circle is the parent, purple is the child

I want the blue circle to have a round frame, allowing this:

enter image description here

Any suggestion on how to achieve that, without using images? Thanks a lot!

Tomer Rubin
  • 173
  • 2
  • 17

1 Answers1

0

This view works for you. https://github.com/google/iosched/blob/master/android/src/main/java/com/google/samples/apps/iosched/ui/widget/BezelImageView.java

It clip bitmap using the mask defined by you.If you want to achieve your goal,you can use it like these below:

<BezelImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content”   
    app:maskDrawable="@drawable/default_circle_mask"
/>

default_circle_mask.drawable:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#000" />

banking
  • 480
  • 2
  • 9