【发布时间】:2016-10-29 19:39:35
【问题描述】:
我需要创建一个圆角边框,其中带有渐变的边框。enter link description here 正在工作。但是我的页面使用的图像作为背景,也带有渐变。我需要从字段中间显示背景图像。我想创建如下图:
【问题讨论】:
我需要创建一个圆角边框,其中带有渐变的边框。enter link 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 .. 享受。 :}
【讨论】: