LinearLayout not expanding inside a ScrollView

Posted by Felix on Stack Overflow See other posts from Stack Overflow or by Felix
Published on 2010-04-08T12:38:15Z Indexed on 2010/04/08 13:13 UTC
Read the original article Hit count: 652

Filed under:
|

I have a LinearLayout inside a ScrollView that has android:layout_height="fill_parent", but it doesn't expand to the full height of the ScrollView. My layout looks something like:

level    layout    layout_width    layout_height
1    LinearLayout    fill_parent    fill_parent
2    LinearLayout    fill_parent    wrap_content
3    (some irrelevant stuff)
2    ScrollView      fill_parent    fill_parent <-- this expands full height
3    LinearLayout    fill_parent    fill_parent <-- this does not (has orientation=vertical)
(following stuff probably are irrelevant, but just to be sure:)
4    TextView        fill_parent    fill_parent
4    LinearLayout    fill_parent    wrap_content

I can see that the LinearLayout doesn't expand the full height of the ScrollView because in Eclipse in Android Layout Editor, if I select the ScrollView (in the Outline panel) it is highlighted with a red border that fills the screen to the bottom but when I select the LinearLayout its highlight doesn't expand to the bottom of the screen. How can I get it to do so?

The effect I'm trying to achieve is to have some text and a button below it (inside the LinearLayout in level 4 there's just a button). The text can be big enough to need a scrollbar, in which case I want the user to have to scroll down in order to see the button. In case the text is not big enough for a scroll bar, I want the LinearLayout containing the button to stick to the bottom of the screen.

© Stack Overflow or respective owner

Related posts about android

Related posts about android-layout