View Background Image 无法正确包装内容,造成一些边距

View Background Image can't wrap content properly, making some margins

我的视图背景图像产生了一些我不需要的奇怪边距。这是照片:

如您所见,TextView 已突出显示,并且 View(带有蓝色背景图像)应该环绕该 TextView,但看起来 TextView 正在制作一些边距。 这是 XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:background="@color/white_as_stone">

<LinearLayout
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/circle_user"
    android:id="@+id/view_user"

    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_marginLeft="@dimen/view_margin_to_side"
    android:layout_marginStart="@dimen/view_margin_to_side"
    android:layout_marginTop="@dimen/side_margins"
    android:layout_marginRight="@dimen/side_margins"
    android:layout_marginEnd="@dimen/side_margins">
    <!-- margins above have nothing to do with my problem -->

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:text="why y doing this?"
        android:id="@+id/txt_user"
        android:textColor="@color/white_as_stone">
        </TextView>
</LinearLayout>

这是我的背景图片:

我对 9-patch drawables 没有太多经验,我尝试调整比例区域,但没有帮助。感谢任何帮助。

您需要增加 9patch 图片底部和右侧的黑线。它们定义图像的可用内容区域。