Wednesday, November 4, 2009

[android-developers] ScrollView Layout/Gravity Problem

I would like to have a scrollable layout with some buttons at the
bottom. Getting the buttons to the bottom when using a Linear Layout
works, however once I add a ScrollView it doesn't. Below is an
example demonstrating my problem (I know there isn't enough content to
benefit from scrolling)

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF">

<LinearLayout
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello" />

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" android:gravity="bottom">

<Button
android:text="Something" android:id="@+id/btn2"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />

<Button
android:text="Something Else" android:id="@+id/btn1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1" />

</LinearLayout>

</LinearLayout>

</ScrollView>

Changing the gravity(=bottom) will push the Linear Layout containing
the buttons to the bottom of the outer Linear Layout container, but
that isn't at the bottom of the layout. Why when there is a
ScrollView involved does it prevent layout_height="fill_parent" from
filling the entire layout?

I found a post on same problem but there were never any answers.

http://markmail.org/message/ftiyzo7mvr45qv3g

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment