我如何实现以下xml布局?

问题描述 投票:0回答:2

我制作的版面

enter image description here

我想实现的布局

enter image description here

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>

enter image description here

我想使自定义可绘制对象如下所示,以使它不会被剪切Earned Badges文本视图。

made in paint

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

android-layout android-xml android-custom-drawable
2个回答
3
投票

您可以通过将背景添加到textView(Earned Badges)来实现此目的,该背景具有android:background="@drawable/your_custom_button"角和黑色,它将与橙色鹳重叠。

希望它能对您有所帮助。


0
投票

由于@noureldien mohamed的方式目前似乎可行,但是如果您真的想像您提到的那样创建可绘制对象,则应尝试制作vector。这是您喜欢的一个。

<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" />

[OUTPUT

] >>

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.