I'm trying to use a linear layout's layout_weight for the height inside of a scrollview. However I find that layout_weight would only work with fillViewPort=true and if there is enough remaining space for the linear_weight to expand.
I have listed three examples below and I want to make textView the same size in #2 and #3 as #1 in xml level. As you can see in the link, in #2, #3, textView was automatically changed.
Here are my examples. The TextViews and Buttons are enclosed inside of a LinearLayout and then inside of a scrollView.
1. Layout_weight working perfectly relative to the parent. (Working)
2. Layout_weight working relative to the remaining space and not the parent.(Not Working)
3 Layout_weight ignored (Not Working)
Here's my xml code for #3. #2 and #1 is basically the same code with less or no buttons.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weighSum="1"
android:fillViewport="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="10" >
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<Button
android:layout_width="30dip"
android:layout_height="30dip"
android:text="Accept" />
<TextView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="6"
android:background="#AAABBB"
android:text="hello" />
<TextView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="#BBBAAA"
android:text="hello" />
<TextView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:background="#AAABBB"
android:text="hello" />
</LinearLayout>
</ScrollView>