gpt4 book ai didi

android - 如何在android布局中制作圆角背景图片?

转载 作者:行者123 更新时间:2023-11-29 00:31:07 26 4
gpt4 key购买 nike

我正在尝试制作带圆角的背景图像,以便在布局中设置它。问题是如何在可绘制 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com