我正在尝试将现有的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惯用的,以及它用于在GridView中加载更多数据的其他UI约定?

谢谢!

最佳答案

您可以在主LinearLayout中放置一个ScrollView。但是,一个ScrollView只能有一个直接子级,因此您需要在其中放入另一个LinearLayout,然后再包含GridView和Button。

10-06 13:45
查看更多