How to get a widget to take up "all the space available

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

How to get a widget to take up "all the space available

Postby ErnestoGuevara » Mon Mar 16, 2009 4:04 am

So I've got a screen layout with a title and the top, a bunch of buttons at the bottom, and a listview in the middle.

I want the listview to take up as much height as it can.

What's my move here? I can set absolute pixels, but I really, really don't want to.
Search "Awesome Android Apps" in the market
http://www.awesomeandroidapps.com
ErnestoGuevara
Experienced Developer
Experienced Developer
 
Posts: 75
Joined: Thu Jan 08, 2009 2:02 am

Top

Postby ErnestoGuevara » Mon Mar 16, 2009 4:49 am

The answer is using the layout_weight attribute, which will override the height/weight specified (depending on whether the enclosing linearlayout is horizontally or vertically aligned). The trick is to make sure nothing at a higher level is at wrap_content, because in that case there isn't any extra room for the weighted element to claim.
Search "Awesome Android Apps" in the market
http://www.awesomeandroidapps.com
ErnestoGuevara
Experienced Developer
Experienced Developer
 
Posts: 75
Joined: Thu Jan 08, 2009 2:02 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google Feedfetcher and 7 guests