0

我做的布局

在此处输入图像描述

我要实现的布局

在此处输入图像描述

orange_hollow_fill_round_corner.xml(自定义可绘制)

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

    <corners android:radius="15dp" />

    <stroke
        android:width="1dp"
        android:color="@color/orange" />

    <size
        android:width="80dp"
        android:height="20dp" />

</shape>

在此处输入图像描述

我想制作如下所示的自定义可绘制对象,这样它就不会剪切“已获徽章文本”视图。

用油漆制成

请忽略我想要实现的布局和布局的角落和颜色的差异。

4

2 回答 2

4

您可以通过将背景添加到 textView(Earned Badges)来做到这一点,这个背景有角和黑色,android:background="@drawable/your_custom_button"因为它将重叠在 orange stork 上。

我希望它会帮助你。

于 2020-02-04T09:29:09.030 回答
0

正如@noureldien mohamed 方式现在似乎可行,但如果你真的想像你提到的那样创建可绘制的,你应该尝试制作矢量。这里是你喜欢的那个。

<vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt"
android:viewportWidth="326.33"
android:viewportHeight="76.25"
android:width="326.33dp"
android:height="76.25dp">
<path
    android:pathData="M201.13 2h109.2c7.7 0 14 6 14 13.25V61c0 7.29 -6.3 13.25 -14 13.25H16c-7.7 0 -14 -6 -14 -13.25V15.25C2 8 8.3 2 16 2h92.42"
    android:strokeColor="#FC7F2D"
    android:strokeWidth="3"
    android:strokeLineCap="round"
    android:strokeLineJoin="round" />

输出

在此处输入图像描述

于 2020-02-05T05:46:12.317 回答