TableLayout and layout_weight



I am trying to understand how layout_weight works in a TableLayout. In the layout provided for the HelloMoonFragment, the ImageView has a layout_weight of 1 and the TableRow has a layout_weight of 0. That kind of puzzles me. If I change the layout_weight of the ImageView to 0, the TableRow isn’t displayed. Can someone explain to me how layout_weights work in a TableLayout context? It isn’t explained in the book and I can’t find anywhere that explains it. If I apply the definition for LinearLayout, it should be the TableRow to have a higher layout_weight than the ImageView… Thank you very much and I am loving your book!


By the way, I just got another question in the same layout:

Again, in HelloMoonFragment’s layout:

Why is the layout_gravity of TableRow set to “center|bottom”? If I use just center it seems to give the same results. Is there any reason for this that I am not understanding? Thank you very much.



1- The usage of layout_weight is the same in TableLayout. The TableRow is likely not displayed because the ImageView is larger than it would normally be.

2- With layout_weight being defined the way it is, the “bottom” part of the layout_gravity is superfluous.