笔者最近在搞UI编程的时候,将默认创建的layout(AbsoluteLayout)改为LinearLayout后报了如下的错:
Wrong orientation? No orientation specified, and the default is
horizontal, yet this layout has multiple children where at least
one has layout_width="match_parent"
上网查了下明白了,错误提示的意识是说未给LinearLayout指定方向,LinearLayout的默认方向是水平,这其实没什么,也不应该报错,但问题是这个布局下有多个layout_width="match_parent"的子控件。那么问题就来了,水平方向的布局就会把所有空间沿水平方向挨个向后排,如果第一个空间的layout_width就match_parent了,那它后面的控件不就看不见了吗。所以要给LinearLayout指定方向,加一行代码就OK。
android:orientation="vertical"
作者在UI编程中将默认的AbsoluteLayout改为LinearLayout后报错,原因是未给LinearLayout指定方向,其默认水平方向,而布局下有多个layout_width为match_parent的子控件,会导致后续控件不可见,解决办法是添加android:orientation=\vertical\代码。
1129

被折叠的 条评论
为什么被折叠?



