问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/7105390/why-nine-patch-image-in-relativelayour-hides-all-inner-elements