Android ImageView 圆角实现 系统自带控件

CardView为Android系统自带控件,使用CardView包裹ImageView也可以实现圆角效果,需要注意的是,CardView有可能会影响到控件层级,可以通过设置app:cardElevation="0dp"避免该问题:

<androidx.cardview.widget.CardView
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="50dp"
        app:cardCornerRadius="10dp"
        app:cardElevation="0dp">

        <ImageView
            android:id="@+id/iv_beauty"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/beauty1" />

    </androidx.cardview.widget.CardView> 
 

猜你喜欢

转载自blog.csdn.net/GUOZIJUN01/article/details/128010081