简体   繁体   中英

Why nine-patch image in RelativeLayour hides all inner elements?

When I set 9.PNG image as RelativeLayout 's background, all elements inside it gets shrunken to the middle. Here is the XML and the snapshot.

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

九补丁背景

If I change background to a color or a normal image, I get the text.

android:background="@drawable/bg2" //normal image

正常图像背景

Can anyone explain why is this happening?

Did you define the content area of your nine-patch? Because it looks like the content area is the little pixel in the middle.

The content area is defined by the bottom and right sides of your nine patch. You can for example make it as big as your patch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM