Android: trying to understand android:layout_weight

I'm trying to divide a page in three parts. I'd like to do it in percentage values, however that is not supported by Android. Instead I have to use android:layout_weight. But I have a hard time understanding it and getting it right. Especially how the actual size gets calculated. Is there a way to get a percentage value (0..100%) out of android:layout_weight?

I went through a few cases (see attached screenshot) to describe the problems. The colored fields are all with android:layout_height="fill_parent", because I want the full screen to be divided between those.

Case 1

alt text

Okay, simple. Every gets 33%.

Case 2

alt text

Ups?! The first (yellow) disappears completely? Why?

Case 3

alt text

Confused again. The yellow is back. However, the two first with the heavier weight get smaller? What is going on?

Case 4

alt text

I have absolutely no idea what the maths behind all this is.

19
задан divibisan 16 May 2019 в 20:31
поделиться