gpt4 book ai didi

Android形状边框渐变中间透明

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:43:02 28 4
gpt4 key购买 nike

我需要创建一个圆角边框,其中边框带有渐变。 enter link description here正在工作。但是我的页面正在使用图像作为背景,该图像也带有渐变。我需要从字段中间显示背景图像。我想创建如下图所示:enter image description here

最佳答案

round_background.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="4dp"
android:color="@color/transparent" />
<gradient
android:startColor="#374533"
android:centerColor="#432727"
android:endColor="#222430"
android:angle="135"/>
<corners android:radius="10dp" />
</shape>

round_border.xml

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

<gradient
android:startColor="#efe301"
android:centerColor="#7dc17b"
android:endColor="#01dae6"
android:angle="180"/>
<corners android:radius="10dp" />

result_drawable.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@drawable/round_border"/>
<item android:drawable="@drawable/round_background" />

</layer-list>

在这里,您可以在 round_background.xml 中设置 android:width="4dp"来设置边框的大小。在你想要的地方使用结果 result_drawable.xml ..享受。 :

关于Android形状边框渐变中间透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40322955/

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