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

Creating a rounded image

RioLeal

Newbie
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.
 
Thank you for letting us know about this. Your feedback helps us to get better.
 
Last edited by a moderator:
Back
Top Bottom