I want to make the ImageView round, without a picture it turns out, but if you specify the android:src attribute, then the ImageView immediately becomes square. How to fix it?

ImageView markup:

 <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/profile_photo" android:src="@drawable/no_photo" android:id="@+id/profile_photo" /> 

Markup @drawable/profile_photo :

 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/white"/> <corners android:radius="150dip" /> </shape> 

    1 answer 1

    Whatever background you specify for a view view, it will not change its rectangular real size. The round background is just a transparent rectangle with an opaque circle. For your purposes it is best to take one of the many libraries. For example, here:

    CircleImageView - https://github.com/hdodenhof/CircleImageView