gpt4 book ai didi

java - 通过网格/ ListView 将 View 推离屏幕

转载 作者:行者123 更新时间:2023-12-01 14:07:40 24 4
gpt4 key购买 nike

我已经对这个问题做了一些研究,找到了一些主题,但没有任何帮助我。

这就是我所拥有的:

<RelativeLayout 
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">

<GridView
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="2"
android:padding="5dp"/>

<EditText
android:id="@+id/edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"/>

</RelativeLayout>

我遇到的问题是,当我的网格中有太多元素时,编辑文本会被推离屏幕。我尝试在 editText 上使用alignParentBottom,但这不是我想要的。

我想知道是否有任何方法可以使编辑文本始终可见,即使 GridView 中有许多元素,并且将编辑文本保持在网格下方并且不与父级底部对齐。我还尝试使用 ScrollView 而不是相对布局...但这也是错误的,因为在 ScrollView 内使用 GridView 有太多错误。

我希望我已经说清楚了,请随时询问更多信息。

谢谢你

最佳答案

您也可以使用简单的 LinearLayout 来实现此目的:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<GridLayout
android:id="@+id/grid"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:numColumns="2"
android:padding="5dp" />

<EditText
android:id="@+id/edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:padding="5dp" >

<requestFocus />
</EditText>

</LinearLayout>

我体验过 LinearLayoutRelativeLayout 更快、更健壮,但这只是个人观点。

关于java - 通过网格/ ListView 将 View 推离屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18768545/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com