意见箱
恒创运营部门将仔细参阅您的意见和建议,必要时将通过预留邮箱与您保持联络。感谢您的支持!
意见/建议
提交建议

android中imageview圆角如何实现

来源:恒创科技 编辑:恒创科技编辑部
2024-04-29 14:11:40

在Android中,可以通过使用ImageViewBackground属性来为ImageView设置圆角。

以下是一个示例代码来实现ImageView圆角的效果:

<ImageView
    android:id="@+id/image"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:background="@drawable/circle_background"
    android:src="@drawable/your_image"
    android:scaleType="centerCrop" />

然后在drawable文件夹中创建一个circle_background.xml文件,内容如下:


android中imageview圆角如何实现

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <corners android:radius="50dp" />
</shape>

这样就可以实现ImageView圆角的效果,其中android:radius属性的值可以根据需要进行调整。

上一篇: ubuntu中aptitude的用途有哪些 下一篇: android圆角图片怎么设置