在 Shape Drawable 中调整高度

问题描述

我有一个形状可绘制资源文件。
这是下面的 drawable.xml 代码。

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:left="-2dp"
          android:bottom="-2dp"
          android:top="-2dp">
        <shape android:shape="rectangle">
            <stroke android:width="@dimen/px02"
                    android:color="@color/white" />
        </shape>
    </item>
</layer-list>

这是布局xml代码。

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/gray333"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!!!"
        android:textColor="@color/black"
        android:background="@drawable/bg_category_border"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

结果就是这样。

enter image description here

您可以看到左侧的白条。
我想让条形尺寸更短,顶部和底部与 TextView 的文本一样高。(红线)
我试图在 drawable.xml 中给出填充和大小。
我在 TextView 上设置了 android:includeFontPadding。
但它没有用。
我该怎么做??

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)