Android 为什么listVIew位于EditText后面?
大家好,我有一个问题,当listview增长时,它会落后于editText。。。我不想让它落后于风景。。我想让它在编辑文本中停留。。你能帮我吗?我感谢你的帮助Android 为什么listVIew位于EditText后面?,android,listview,android-edittext,android-linearlayout,Android,Listview,Android Edittext,Android Linearlayout,大家好,我有一个问题,当listview增长时,它会落后于editText。。。我不想让它落后于风景。。我想让它在编辑文本中停留。。你能帮我吗?我感谢你的帮助 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_height="match_parent"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:paddingBottom="10dp"></ListView>
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="2">
<EditText
android:id="@+id/edit_text"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_column="0"
android:layout_row="0"
android:layout_gravity="fill_horizontal|bottom"
android:hint="Type text here..."
android:maxLines="3"
android:scrollbars="vertical"
android:maxEms="10"/>
<Button
android:id="@+id/button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_column="1"
android:layout_row="0"
android:text="Send"
android:layout_gravity="bottom"
android:onClick="insertTo"
/>
</GridLayout>
</LinearLayout>
尝试此操作,更改视图的权重
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:weightSum="1">
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_weight="0.97"
android:layout_height="0dp"
android:paddingBottom="10dp"></ListView>
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.03"
android:columnCount="2">
<EditText
android:id="@+id/edit_text"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_column="0"
android:layout_row="0"
android:layout_gravity="fill_horizontal|bottom"
android:hint="Type text here..."
android:maxLines="3"
android:scrollbars="vertical"
android:maxEms="10"/>
<Button
android:id="@+id/button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_column="1"
android:layout_row="0"
android:text="Send"
android:layout_gravity="bottom"
android:onClick="insertTo"
/>
</GridLayout>
</LinearLayout>
尝试此操作,更改视图的权重
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:weightSum="1">
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_weight="0.97"
android:layout_height="0dp"
android:paddingBottom="10dp"></ListView>
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.03"
android:columnCount="2">
<EditText
android:id="@+id/edit_text"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_column="0"
android:layout_row="0"
android:layout_gravity="fill_horizontal|bottom"
android:hint="Type text here..."
android:maxLines="3"
android:scrollbars="vertical"
android:maxEms="10"/>
<Button
android:id="@+id/button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_column="1"
android:layout_row="0"
android:text="Send"
android:layout_gravity="bottom"
android:onClick="insertTo"
/>
</GridLayout>
</LinearLayout>
从列表视图中删除:
android:layout\u weight=“1”
它看起来像:
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"></ListView>
从列表视图中删除:
android:layout\u weight=“1”
它看起来像:
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"></ListView>
使用RelativeLayout作为xml的根视图 为GridLayout指定一个id,并使其对齐parentbottom=“true”。将ListView保持在GridLayout上方。它应该是这样的:
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/gridviewItem">
</ListView>
and GridView item should look like:
<GridLayout
android:id="@+id/gridviewItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.03"
android:columnCount="2">
和GridView项应如下所示:
//网格视图项
/>
希望这有助于……使用RelativeLayout作为xml的根视图 为GridLayout指定一个id,并使其对齐parentbottom=“true”。将ListView保持在GridLayout上方。它应该是这样的:
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/gridviewItem">
</ListView>
and GridView item should look like:
<GridLayout
android:id="@+id/gridviewItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.03"
android:columnCount="2">
和GridView项应如下所示:
//网格视图项
/>
希望这有帮助……它不会落后于
editText
,它是在listview
边界末尾滚动文本的最后一个限制。它不会落后。这是默认行为,因为您的主布局是线性布局,并且子对象垂直对齐。由于在listview中填充底部,它不会在编辑文本
后面显示,这是在listview
边界末尾滚动文本的最后一个限制。它不会在后面显示。这是默认行为,因为您的主布局是线性布局,并且子对象垂直对齐。由于在listview中填充了bottom,所以显示为这样