views:

76

answers:

2

Question If I have the following:

<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
    <LinearLayout android:layout_width="fill_parent" android:layout_height="?" android:orientation="vertical">
        <EditText android:layout_width="fill_parent" android:layout_height="?" android:hint="Subject" android:id="@+id/subject" />
        <EditText android:layout_width="fill_parent" android:layout_height="?" android:id="@+id/body" />
    </LinearLayout>
</ScrollView>

How can I get the body (second EditText) to fill the rest of the screen, but still have the scrollview kick in when the contents of the body are too long? Like a height="wrap_content" and minHeight="fill_parent"

layout_height="fill_parent" seems to not do anything if you put them in a scrollview

A working example of what I want is the email app compose window

I tried this and the EditText elements act like they are wrap_content and no filling is happening. Just scrolling if you type enough

<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
    <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">
        <EditText android:layout_width="fill_parent" android:layout_height="fill_parent" layout_weight="1" android:hint="Subject" android:id="@+id/subject" />
        <EditText android:layout_width="fill_parent" android:layout_height="fill_parent" layout_weight="1" android:id="@+id/body" />
    </LinearLayout>
</ScrollView>
A: 

Why don't you make the ScrollView being fill_parent and A and B to wrap_content ? The only thing you want is that your ScrollView fits the screen.

fedj
I also want textarea B to fill the screen. Like a min-height: fill_parent.
cjavapro
Try with a LinearLayout and layout_weight="1" on each A and B with layout_height="fill_parent" on A and B too
fedj
See my code example above
cjavapro
A: 

I ran across a link to the mail app source code in my accepted answer on another question. The answer is simple! Add android:fillViewport="true" to the <ScrollView...>

cjavapro