2011-08-18 26 views
3

當我將9.PNG圖像設置爲RelativeLayout的背景時,它內部的所有元素都縮小到中間。這裏是XML和快照。爲什麼RelativeLayour中的九貼圖隱藏了所有內部元素?

<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

如果更改背景顏色或正常的圖像,我得到的文本。

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

normal-image background

誰能解釋爲什麼會出現這種情況?

+0

你的問題的明確答案在這裏提供:http://stackoverflow.com/questions/3904852/android-layout-broken-with-9-patch-background –

回答

6

您是否定義了九個補丁的內容區域?因爲它看起來像內容區域是中間的小像素。

內容區域由您的九個補丁的底部和右側定義。例如,你可以把它做得和你的補丁一樣大。

相關問題