Say I have a vertical LinearLayout and several TextViews in it with layout_height set to wrap_content.
This way the last TextView becomes clipped at the bottom:

Setting layout_height="match_parent" and layout_weight="1" for each TextView ‘solves’ this problem:
Unfortunately, this leads to very large intervals between views in portrait layout:
So, is there any way to arrange items on the screen so that:
- They all fit into the screen
- If the screen is large, they should be placed one by one without huge spaces between them, having, however, free space at the bottom
?
Thanks a lot in advance.
This is one of the cases where you should use different layout resources for different configurations. For example, based on your example you could have a
layout-landfolder for when the phone is in landscape and in that layout use the xml layout where all theTextViewshavelayout_weight="1". For portrait orientation(and the default layout) you could have in yourlayoutfolder a layout file like the one from thelayout-landto which you would add this element after theTextViews:This empty
Viewwill “absorb” some of the empty space so you don’t have a big gap between theTextViews.The different layout files for different screen could be improved by using further refined layouts for screens of different size(normal, large, very large) combined with different orientations(portrait vs landscape).
Of course, you could write your own layout manager to position the child
TextViewsbut this isn’t something easy to do.