I know that it is impossible to set percentages and that you can set a weight of certain images to scale their heights. What I am trying to do though is specify the height of a layout relative to the layout it is within. Basicly I have something like this
<LinearLayout android:layout_height="fill_parent">
<LinearLayout>
</LinearLayout>
</LinearLayout>
Of course this is a very simplified version, just so you can understand my gibberish. Basicly I want to set the inner linearlayout to be around 50% of the main linearlayout.
What is the best way to do this?
With introduction of ContraintLayout, it's possible to implement with Guidelines:
You can read more in this article Building interfaces with ConstraintLayout.
There is an attribute called android:weightSum.
You can set android:weightSum="2" in the parent linear_layout and android:weight="1" in the inner linear_layout.
Remember to set the inner linear_layout to fill_parent so weight attribute can work as expected.
Btw, I don't think its necesary to add a second view, altough I haven't tried. :)
Just as you said, I'd recommend weights. Percentages would be incredibly useful (don't know why they aren't supported), but one way you could do it is like so:
The takeaway being that you have an empty View that will take up the remaining space. Not ideal, but it does what you're looking for.
You could add another empty layout below that one and set them both to have the same layout weight. They should get 50% of the space each.