How to have a curcular ImageView. This is my xml
<RelativeLayout
android:id="@+id/imgUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:background="@drawable/circle_border">
<ImageView
android:id="@+id/studentimg"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_margin="9dp"
android:adjustViewBounds="true"
android:background="@drawable/circlepf"
android:padding="3dp"
android:scaleType="centerInside"
android:src="@drawable/ic_profile" />
</RelativeLayout>
this is my problem image sample
but I want this image to show in circular view
Simply put a circular_crop. png in your drawable folder which is in the shape of your image dimensions (a square in my case) with a white background and a transparent circle in the center. You can use this image if you have want a square imageview.
You can use the Material Components Library.
With the version 1.2.0-alpha03
there is the new ShapeableImageView
.
<com.google.android.material.imageview.ShapeableImageView
...
android:scaleType="centerInside"
android:adjustViewBounds="true"
app:shapeAppearanceOverlay="@style/circleImageView"
app:srcCompat="@drawable/ic_profile" />
with:
<style name="circleImageView" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With