gpt4 book ai didi

android - 在 Android 上的 GridView 底部获取一个按钮以滚动到 View 中

转载 作者:行者123 更新时间:2023-11-29 14:10:32 30 4
gpt4 key购买 nike

我正在尝试将现有的 iPhone 应用程序移植到 android。我希望在 GridView 的底部有一个按钮滚动到 View 中,以使用户能够从服务器加载更多数据。目前,我的解决方案只是在屏幕底部固定一个按钮,而不是让它滚动到 View 中。

这是我的布局代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/grid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:columnWidth="70dp"
android:numColumns="auto_fit"
android:verticalSpacing="0dp"
android:horizontalSpacing="0dp"
android:stretchMode="columnWidth"
android:gravity="center"
android:background="#000000"
/>
<Button
android:id="@+id/load_more"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Load More"
/>
</LinearLayout>

将按钮固定在屏幕底部是行不通的,因为我打算在底部放置一个广告。

任何人都可以从概念上解释如何让加载更多按钮滚动到 View 中,或者为我指出一些示例代码,或者告诉我为什么这不是 Android 惯用的以及它使用什么其他 UI 约定来加载更多数据一个 GridView ?

谢谢!

最佳答案

您可以在主 LinearLayout 中放置一个 ScrollView。不过,ScrollView 只能有一个直接子级,因此您需要在其中放置另一个 LinearLayout,然后它会包含您的 GridView 和 Button。

关于android - 在 Android 上的 GridView 底部获取一个按钮以滚动到 View 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3670176/

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