Question

Setting two or more elements of a linear layout the same height seems to be a great problem.

I want to set four buttons in a row to the same height.

android:layout_height="wrap_content" does it for the moment but when the text on one of the buttons is longer than one line this button is increased and therefore bigger than the other ones. Due to different localisations I don't know, when and which button may have a second line.

So my idea is, to set the parent linearlayout to android:layout_height="wrap_content" and all (!) child heights to android:layout_height="fill_parent".

This works (all buttons have the same size), but I'm not sure if this causes any other problems? Because it the parent gets it's height from the childs and vice-versa.

Was it helpful?

Solution

In theory what you are describing should not work ("Because it the parent gets it's height from the childs and vice-versa".) However, we made it work in LinearLayout because it was a very common use case. I recently added similar support to FrameLayout (this feature should be part of Honeycomb.) What you are doing is therefore perfectly valid and will work just fine.

OTHER TIPS

That doesn't make sense :(

Why don't you use android:singleLine="true" and some ellipsode?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top