I’m curious what I need to do if I want a layout to occupy the right side of the screen, regardless of screen size.
Do I have to put some empty element with a weight of 1 as the left side? Or is it possible to just specify that a layout align itself with the right side of its parent and take up some percentage? And if so… how? Ideally the parent is a RelativeLayout, but I’ll work with whatever solution works cause at present everything I’ve tried results in something entirely wrong.
As far as I know, the only solution is to have a weighted
LinearLayout. The view’s weight divided by the layout weightSum represents the percentage of the free space on the screen.You can make it have two child views with each width set to 0dp and weight set to 1.
Weighted layouts work in two phases: The first phase measures the
layout_widthof each view. The second phase distributes any remaining space (total layout width – accumulated sum of each view’s width) regarding thelayout_weight/weightSumrelation.