[英]Top rounded corner on an ImageView
如何将顶部圆角添加到 ImageView。 我已经尝试过以下方法,但它不起作用。
imgView.setClipToOutline(true);
最好在顶部创建具有半径的可绘制文件并将其设置为背景。
您可以为此创建一个 drawable 或使用此库以获得更好的结果
您可以创建自定义背景
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@android:color/darker_gray"/>
<corners android:topRightRadius="10dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="10dp"
android:bottomLeftRadius="0dp"/>
</shape>
像这样在 imageview 中设置
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:background="@drawable/shape"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.