2011-12-23 88 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"