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

半城伤御伤魂 提交于 2019-12-10 19:39:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!