Reputation: 79615
I'm trying to implement a layout in android which consists of several TextView
s and some buttons. I want one of the TextView
s (which is a log of the game I'm implementing) to take up all available space it has, and be scrollable if there's too much text to display. However, I can't seem to get it to no overlay views below it when it expands - instead, it stop at the bottom of the screen:
In this screenshot, there's a "scoreboard" TextView, a "hand" TextView, a "log" TextView and a LinearLayout with several buttons. All TextView
s have dynamic length, but the first two aren't supposed to take up more than a few lines. The Trouble is, that the log expands and covers the button below it (on the plus side, it is scrollable). Can you show me how to fix this?
Here's the layout XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/scoreboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="Scoreboard" />
<TextView
android:id="@+id/handinfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/scoreboard"
android:text="Hand" />
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button
android:id="@+id/stay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:text="Stay" />
<Button
android:id="@+id/leave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:text="Leave" />
<Button
android:id="@+id/pay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:text="Pay" />
<Button
android:id="@+id/payWithWild"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:text="Pay Wild" />
<Button
android:id="@+id/dontPay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:text="Don't Pay" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/handinfo" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/log"
android:text="" />
</ScrollView>
</RelativeLayout>
Upvotes: 2
Views: 1174
Reputation: 68167
Add the following attributes to your ScrollView
and it should fix the display:
android:layout_below="@id/handinfo"
android:layout_above="@id/linearLayout1"
Upvotes: 4