为什么RelativeLayour中的九个补丁图像会隐藏所有内部元素?

san*_*one 3 android nine-patch relativelayout

当我将9.PNG图像设置为RelativeLayout背景时,其中的所有元素都缩小到中间.这是XML和快照.

<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/bg"
        >
    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Just a simple white text which does not show up"
            android:textColor="#ffffff"
            />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

九补丁背景

如果我将背景更改为颜色或普通图像,我会得到文本.

android:background="@drawable/bg2" //normal image
Run Code Online (Sandbox Code Playgroud)

正常图像背景

谁能解释为什么会这样?

Zol*_*eas 6

你定义了9补丁的内容区域了吗?因为看起来内容区域是中间的小像素.

内容区域由九个补丁的底部和右侧定义.例如,您可以使其与补丁一样大.