对家长和FILL_PARENT儿童组合WRAP_CONTENT [英] combining wrap_content on parent and fill_parent on child

查看:141
本文介绍了对家长和FILL_PARENT儿童组合WRAP_CONTENT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置的线性布局的两个或更多个元件的高度相同似乎是一个很大的问题。

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.

机器人:layout_height =WRAP_CONTENT做它的时刻,但是当上的按钮中的一个的文本是多于一行这个按钮被增加,因此比其他的更大。由于不同的本地化不知,何时以及哪些按钮可以具有第二线

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.

所以我的想法是,为设置父的LinearLayout到Android:layout_height =WRAP_CONTENT和所有子高到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.

推荐答案

在理论上你描述的应该是不行的(因为它的母公司得到它的从孩子的,反之亦然高度。)但是,我们做到了在LinearLayout中工作,因为这是一个非常常见的情况。我最近的FrameLayout添加类似的支持(此功能应该是蜂窝状的一部分。)你在做什么,因此完全有效的,并会工作得很好。

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.

这篇关于对家长和FILL_PARENT儿童组合WRAP_CONTENT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆