我有以下代码:
<linearLayout androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" > <EditText androID:ID="@+ID/editText1" androID:layout_wIDth="0dp" androID:layout_height="150dp" androID:layout_weight="3" androID:inputType="textMultiline" > </EditText> <TextVIEw androID:layout_wIDth="0dp" androID:layout_height="wrap_content" androID:layout_gravity="top" androID:layout_weight="1" androID:text="@string/new_post_txt_description" /></linearLayout>
显然androID:layout_gravity =“top”不会将TextVIEw移动到最近.谁知道如何实现这一目标?
P.S
我看到了一些关于使用relativeLayout的想法,但在我的情况下,我需要两个控件彼此相邻并使用权重属性,如示例中所示.
谢谢!
解决方法:
将textVIEw更改为此对我有用
<TextVIEw androID:layout_wIDth="0dp" androID:layout_height="fill_parent" androID:gravity="top" androID:layout_weight="1" androID:text="TEST" />
这利用了重力而不是layout_gravity,但由于textVIEw的高度设置为fill_parent,因此它具有相同的效果
androID:gravity设置其使用的VIEw内容的重力.
androID:layout_gravity在其父级中设置视图或布局的重力.
以上是内存溢出为你收集整理的android – layout_gravity在LinearLayout中不起作用全部内容,希望文章能够帮你解决android – layout_gravity在LinearLayout中不起作用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)