我正在尝试制作一个带有圆角的背景图像,以便在布局中设置它。问题是如何在可绘制 XML 中设置圆角图像而不是使用纯色。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<!-- you can use any color you want I used here gray color-->
<solid android:color="#ffffff"/>
<corners
android:bottomRightRadius="10dp"
android:bottomLeftRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"/>
</shape>
最佳答案
这对我有用:只需将文件名round_corners.xml添加到drawable
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="@color/lemon" android:endColor="@color/lemon_cream" android:angle="90" />
<corners android:radius="30dp" />
</shape>
将此 XML
添加到文件中并享受圆角效果。
关于android - 如何在android布局中制作带有圆角的背景图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15674633/