2011-12-23 85 views
0

我正在嘗試使用Header,圖像和滾動文本主體進行線性佈局。出於某種原因,ScrollView似乎總是佔用儘可能多的空間,因爲它通常需要重疊標題和圖像。我已經嘗試爲每個對象分配權重,但它不會改變任何內容。滾動視圖不能保持大小

這裏是我的線性佈局

<LinearLayout android:id="@+id/gamedescriptionlayout" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" 
      android:background="@drawable/backdrop9" 
      android:visibility="visible" 
      android:layout_marginBottom="20dp" 
      android:layout_marginTop="20dp" 
      android:layout_marginLeft="20dp" 
      android:layout_marginRight="20dp" 
      android:layout_gravity="center"> 

<TextView android:id="@+id/DescHeader" 
      android:layout_height="wrap_content"  
      android:layout_width="fill_parent" 
      android:layout_marginBottom="10dp" 
      android:layout_marginTop="10dp" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:gravity="center_horizontal" 
      android:textColor="#000000" 
      android:text="Level 1" 
      android:textSize="25dp" 
      android:layout_weight="1"/> 

<ImageView android:id="@+id/DescImage" 
      android:layout_height="wrap_content"  
      android:layout_width="fill_parent" 
      android:layout_below="@id/DescHeader" 
      android:gravity="center" 
      android:src = "@drawable/wall" 
      android:layout_weight="1"/> 

<ScrollView android:id="@+id/DescScroll" 
      android:layout_height="wrap_content"  
      android:layout_width="fill_parent" 
      android:layout_marginBottom="10dp" 
      android:layout_marginTop="10dp" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:layout_weight="1"> 

<LinearLayout android:id="@+id/DescContainer" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content"> 
<TextView android:id="@+id/DescBody" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:textColor="#000000" 
       android:text="HelloWorld LALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALA"/> 
</LinearLayout> 
</ScrollView> 

</LinearLayout> 

我也試圖把文本主體自身的線性佈局內(見上文),但沒有avial。

回答

1

試試這個:

<LinearLayout android:id="@+id/gamedescriptionlayout" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" 
      android:background="@drawable/backdrop9" 
      android:visibility="visible" 
      android:layout_marginBottom="20dp" 
      android:layout_marginTop="20dp" 
      android:layout_marginLeft="20dp" 
      android:layout_marginRight="20dp" 
      android:layout_gravity="center"> 

<TextView android:id="@+id/DescHeader" 
      android:layout_height="wrap_content"  
      android:layout_width="fill_parent" 
      android:layout_marginBottom="10dp" 
      android:layout_marginTop="10dp" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:gravity="center_horizontal" 
      android:textColor="#000000" 
      android:text="Level 1" 
      android:textSize="25dp" 
      android:layout_weight="0"/> 

<ImageView android:id="@+id/DescImage" 
      android:layout_height="wrap_content"  
      android:layout_width="fill_parent" 
      android:layout_below="@id/DescHeader" 
      android:gravity="center" 
      android:src = "@drawable/wall" 
      android:layout_weight="0"/> 

<ScrollView android:id="@+id/DescScroll" 
      android:layout_height="0dp"  
      android:layout_width="fill_parent" 
      android:layout_marginBottom="10dp" 
      android:layout_marginTop="10dp" 
      android:layout_marginLeft="10dp" 
      android:layout_marginRight="10dp" 
      android:layout_weight="1"> 

<LinearLayout android:id="@+id/DescContainer" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content"> 
<TextView android:id="@+id/DescBody" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:textColor="#000000" 
       android:text="HelloWorld LALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALA"/> 
</LinearLayout> 
</ScrollView> 

</LinearLayout> 

現在應該罰款!

+0

神奇的三江源^^ – Jack 2011-12-23 14:19:15

0

變化

android:layout_below="@id/DescHeader" 

android:layout_below="@id/DescImage"