Android 布局图“重力=”;底部“;不起作用
在我的android布局中,我有两个EditText元素。它们并排出现在屏幕底部。但是,当我在第一个编辑文本(左侧)中键入多行时,第二个编辑文本(右侧)也会不断向上移动,即使它是空的。我已经为第二版文本指定了Android 布局图“重力=”;底部“;不起作用,android,Android,在我的android布局中,我有两个EditText元素。它们并排出现在屏幕底部。但是,当我在第一个编辑文本(左侧)中键入多行时,第二个编辑文本(右侧)也会不断向上移动,即使它是空的。我已经为第二版文本指定了android:layout\u gravity=“bottom”和android:gravity=“bottom”。但它没有效果。我做错了什么?如何使second EditText保持在其父线性布局的垂直中心,无论在first EditText中输入了多少行 <?xml versio
android:layout\u gravity=“bottom”
和android:gravity=“bottom”
。但它没有效果。我做错了什么?如何使second EditText保持在其父线性布局的垂直中心,无论在first EditText中输入了多少行
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/bg_textinput"
android:layout_alignParentBottom="true">
<EditText
android:id="@+id/text_input"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="0.7"
android:inputType="textMultiLine" />
<EditText
android:id="@+id/text_input1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="bottom"
android:layout_weight="0.3"
android:inputType="textMultiLine" />
</LinearLayout>
</RelativeLayout>
试试这个
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText
android:id="@+id/text_input"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="0.7"
android:inputType="textMultiLine" />
<EditText
android:id="@+id/text_input1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="0.3"
android:gravity="bottom"
android:inputType="textMultiLine" />
</LinearLayout>
这将起作用:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:gravity="center">
<EditText
android:id="@+id/text_input"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:inputType="textMultiLine" />
<EditText
android:id="@+id/text_input1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="bottom"
android:layout_weight="0.3"
android:inputType="textMultiLine" />
</LinearLayout>
在我的线性布局中使用android:layout\u height=“match\u parent”会导致屏幕上充满我的线性布局。所以我只在我的第二个EditText中使用了它,它部分地起作用,即EditText不再向上移动。但现在它被困在了底部。即使我将重心和布局重心更改为中心,EditText“line”仍位于底部,而文本条目位于中心。如何使线始终保持在垂直中心?移除后的行为相同。i、 e.文本输入位于中心,但线条卡在底部。根据另一个答案的建议,在使用android:gravity=“center”进行线条布局后,它工作正常。谢谢。使用android:gravity=“center”进行线性布局确实有效。但是第二个编辑文本的行仍然保持在底部,即使文本条目位于中间。我在这里提供的其他解决方案中也面临同样的问题。我开始认为这是EditText元素的设计行为。哦,等等,它成功了!在实验过程中,我将第二版文本的布局高度改为“匹配父级”。在我把它改回“包装内容”后,它工作了。谢谢伟大的很乐意帮忙。误导性的回答<代码>布局宽度和布局重量
没有关系。