• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Creating a rounded image

I see many examples of that using implementations and mathematics calcs.

I would like to show my soft way to do this.

Create a CardView object and insert inside it an ImageView object, like this:
HTML:
<androidx.cardview.widget.CardView
                android:id="@+id/cardLogo"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:cardCornerRadius="100dp"
                android:elevation="0dp"
                android:outlineSpotShadowColor="#fff"
                >
                <ImageView
                    android:id="@+id/imgProfile"
                    android:layout_width="200dp"
                    android:layout_height="200dp"
                    android:src="AnyImageYouWant"
                    />
        </androidx.cardview.widget.CardView>
The trick is: the
HTML:
app:cardCornerRadius="100dp"
from CardView will create a rounded borders and will get the size of its son, the ImageView.

In programming time, the image will stay in your real format, but in execution time, the CardView will round the image.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones