How to make buttons, with dynamic text, the same size and width to height ratio?
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?
如果你能够获得相同的高度,你可以对所有按钮使用android:layout_weight =“1”,并把android:layout_width =“0dip”,这样所有按钮的宽度都相同
链接地址: http://www.djcxy.com/p/49958.html上一篇: 我应该使用视图约束还是最小窗口大小?