3

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>

nine-patch background

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

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

normal-image background

Can anyone explain why is this happening?

sandalone
  • 41,141
  • 63
  • 222
  • 338
  • A clear answer of your problem is provided here: http://stackoverflow.com/questions/3904852/android-layout-broken-with-9-patch-background – Mario Kutlev Apr 24 '14 at 08:11

1 Answers1

6

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.

Zoleas
  • 4,869
  • 1
  • 21
  • 33