我正在尝试将现有的 iPhone 应用程序移植到 Android。我希望有一个按钮滚动到 GridView 底部的视图中,以使用户能够从服务器加载更多数据。目前,我的解决方案只是修复屏幕底部的一个按钮,而不是让它滚动到视图中。
这是我的布局代码:
<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>
修复屏幕底部的按钮不起作用,因为我打算在底部放置广告。
任何人都可以从概念上解释如何让“加载更多”按钮滚动到视图中,或者向我指出一些示例代码,或者告诉我为什么这对于 Android 来说不是惯用的,以及它使用什么其他 UI 约定在 GridView 中加载更多数据?
Thanks!
您可以将 ScrollView 放置在主 LinearLayout 中。不过,ScrollView 只能有一个直接子级,因此您需要在其中放置另一个 LinearLayout,其中包含 GridView 和 Button。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)