我希望图像有圆角。我实现了这个 xml 代码并在我的图像视图中使用它。但图像与形状重叠。我正在通过异步任务下载图像。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="20dip" />
</shape>
<ImageView
android:id="@+id/trVouchersImage"
android:layout_width="55dp"
android:layout_height="55dp"
android:layout_marginLeft="8dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_alignParentLeft="true"
android:background="@drawable/ash_arrow"
/>
最简单的方法:
创建一个 xml 文件rounded_fg.xml under 资源/可绘制/您的应用程序的文件夹。内容为rounded_fg.xml如下,
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadiusRatio="2"
android:shape="ring"
android:thicknessRatio="1"
android:useLevel="false">
<gradient
android:type="radial"
android:gradientRadius="8dp"
android:endColor="@color/white"
/>
</shape>
You can 将 endColor 与 ImageView 容器布局背景匹配 & 梯度半径可以是根据您的要求的任何值(
现在使用这个drawable作为前景对于您的图像视图如下,
<ImageView
android:layout_width="55dp"
android:layout_height="55dp"
android:foreground="@drawable/rounded_fg" />
完美配合方形图像和/或图像视图.
方形图像/图像视图:
矩形图像/图像视图:
前景应用于按钮:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)