0

I have a few buttons I want to display in a row in a decision tree. I'm trying to get the buttons in each row of the tree to be the same size. But the buttons have different text. Some have a couple words and some have a sentence. Is there a way I can get the buttons to all be the same size and all maintain the same width to height (4:3) ratio?

I can get the heights the same using fill parent on the button heights while having the parent row layout_height set to wrap_content. How can I get the width of the buttons to be the same size while maintaining a 4:3 width to height ratio. (The width to height ratio constraint is so I don't end up with really tall and thin buttons, which would look silly)

Anyone have any suggestions?

Edit:

I just saw this link which is kinda what I am looking for: Scaling layout with invariant aspect ratio in Android

My problem with this is that it will inflate all the buttons and introduce a lot of empty space around the text inside.

If I could find a way to incrementally increase the width or height (whichever is smaller) of the button and then resize it so it re-"wraps_content", then this could work. Anyone know how to re-wrap the content?

Community
  • 1
  • 1
rmetzger
  • 289
  • 1
  • 3
  • 13

1 Answers1

0

If you are able to get the same height for all you can use android:layout_weight="1" for all buttons and put android:layout_width="0dip" so all buttons will have same width

Ankur Kumar
  • 972
  • 7
  • 12
  • Thanks for the reply but this doesn't quite help. When doing this, the buttons all have the same width, but they try and fill the parent container width (which is the whole screen). So when the buttons have only a couple words in them, they stretch to be very wide and not very high. I am looking for something that always keeps the same width to height ratio. – rmetzger Jan 27 '12 at 15:05