【发布时间】:2021-01-06 07:47:07
【问题描述】:
我想创建一个形状用作元素的背景,因为应用程序有红色和橙色作为主要颜色我想制作一个很酷的边框,但是我只设法找到如何放置一个颜色,真的不知道如何做一个设计。 我想做这样的事情(我在绘画中快速做出这个只是为了展示我的想法):
【问题讨论】:
标签: android-studio colors border shapes
我想创建一个形状用作元素的背景,因为应用程序有红色和橙色作为主要颜色我想制作一个很酷的边框,但是我只设法找到如何放置一个颜色,真的不知道如何做一个设计。 我想做这样的事情(我在绘画中快速做出这个只是为了展示我的想法):
【问题讨论】:
标签: android-studio colors border shapes
好的,我做了一些工作,并找到了一个与我不完全一样的解决方案,但我想它已经足够好了。这是放入drawable文件夹中xml文件的代码:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:shape="rectangle"
android:padding="10dp">
<solid android:color="#FFFFFF"/>
<corners
android:bottomRightRadius="20dp"
android:bottomLeftRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp"/>
<stroke
android:width="10dp"
android:color="@color/colorAccent"/>
</shape>
</item>
<item>
<shape
android:shape="rectangle"
android:padding="10dp">
<corners
android:bottomRightRadius="20dp"
android:bottomLeftRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp"/>
<stroke
android:width="8dp"
android:color="@color/colorPrimary"
android:dashGap="10dp"
android:dashWidth="8dp" />
</shape>
</item>
</layer-list>
这段代码会产生这样的结果:
希望这对任何人都有帮助
【讨论】: