Jack
Jack

Reputation: 2625

Scroll View Not keeping Size

I'm trying to make a linear layout with a Header, an Image and a scrolling text body. For some reason the ScrollView always seems to take up as much space as it needs often overlapping the header and the image. I've tried assigning weight to each of the objects but it does not change anything.

Here is my linear Layout

<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> 

I have also tried putting the text body inside its own linear layout (see above) but to no avial.

Upvotes: 0

Views: 220

Answers (2)

Bill Gary
Bill Gary

Reputation: 3005

change

android:layout_below="@id/DescHeader"

to

android:layout_below="@id/DescImage"

Upvotes: 0

Dimitris Makris
Dimitris Makris

Reputation: 5183

Try this:

<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> 

It should be fine now!

Upvotes: 1

Related Questions