Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android layout height minimum of match_parent, but wrap_content if content is larger than parent

I have a LinearLayout (the content view container) inside a ScrollView. I would like the LinearLayout to have a minimum height of "match_parent" but if the content is taller than the parent, then I want the LinearLayout to be able to "wrap_content".

My LinearLayout has a tiled background image that makes it look like the background is a yellow legal pad. However, if the content in the LinearLayout is short, then I've got a black blank section at the bottom of the screen since the LinearLayout is just wrapping the content.

I want the yellow legal pad background to cover the entire screen but I can't put it on the ScrollView because then the background won't scroll along with the content. I don't want the content to float above the pad, I want them to be anchored together.

Is there any way to achieve this?

EDIT:

Further research.. the ScrollView and LinearLayout are both 683px tall, so they are both the same size, which is good. The problem though is that they should both be 766px tall (the size of the previous fragment which is being replaced by this one).

like image 268
Kenny Wyland Avatar asked Mar 17 '13 21:03

Kenny Wyland


1 Answers

Not really sure I understand why you need this but you can add another let's say linear layout to your scroll view and give it a weight of 0 and your content linear layout can have a weight of 1 so you won't have any dark portions in the scrollview. I hope I'm making some sense :)

like image 130
Cynapsis Avatar answered Sep 27 '22 19:09

Cynapsis