2013-03-31 65 views
0

我有一個線性佈局,我正在使用高度包裝內容。但是,即使在給出包裝內容後,我仍然在所有元素之後獲得一些額外的空間。但是,如果我手動提供高度爲「220dp」,那麼它的格式正確。我想使用包裝內容並解決此問題。請提供您的寶貴建議。額外的空間高度,android xml佈局

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:id="@+id/layout3" android:background="@drawable/question_backgrund" 
    android:orientation="vertical"> 
    <LinearLayout android:layout_width="match_parent" 
     android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="horizontal"> 
     <TextView android:id="@+id/question_number1" 
      android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:layout_marginLeft="5dp" android:textColor="#FF0000" 
      android:text="1" /> 
     <ImageView android:id="@+id/answer_icon1" 
      android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:layout_marginLeft="220dp" android:contentDescription="Answer status" 
      android:src="@drawable/answer_status" android:visibility="invisible" /> 
    </LinearLayout> 
    <LinearLayout android:layout_width="match_parent" 
     android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="horizontal"> 
     <ImageView android:id="@+id/comment_icon" 
      android:layout_width="wrap_content" android:layout_height="wrap_content" 
      android:background="@android:color/transparent" 
      android:layout_marginLeft="15dp" android:layout_marginTop="10dp" 
      android:src="@drawable/write_comments_icon" /> 
     <TextView android:id="@+id/comment_title" 
      android:layout_width="match_parent" android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" android:layout_marginLeft="20dp" 
      android:text="title" /> 
    </LinearLayout> 
    <LinearLayout android:layout_width="match_parent" 
     android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="horizontal"> 
     <LinearLayout android:layout_width="match_parent" 
      android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="horizontal"> 
      <EditText android:id="@+id/write_comments" 
       android:layout_width="wrap_content" android:layout_marginLeft="20dp" 
       android:layout_marginTop="15dp" android:layout_height="100dp" 
       android:ems="10" /> 
      <Button android:id="@+id/submit" android:layout_width="wrap_content" 
       android:layout_marginTop = "10dp" 
       android:background="@drawable/done" 
       android:layout_height="wrap_content" android:layout_marginLeft="10dp" /> 
     </LinearLayout> 
    </LinearLayout> 
</LinearLayout> 

回答

1

爲什麼會出現在主佈局android:layout_weight="1"? 有多少空間?某些元素具有自然填充,如果您只有dp,則可能來自該填充。 它也可能來自主佈局的背景圖像,是9patch圖像嗎?你是否正確地大喊內容以獲取圖像的完整空間?

+0

嗨,感謝您的回覆,它來自背景圖片! – bharath