用于显示图像库的Android视图

用于显示图像库的Android视图,android,android-imageview,android-gridview,android-tablelayout,Android,Android Imageview,Android Gridview,Android Tablelayout,我正在尝试构建一个视图,该视图显示一组被1或2列分割的图像。因此,列的数量和宽度可能会有所不同 我已经查看了现有的视图,但没有一个视图能够满足我的要求 它是否已经存在,或者当前存在的android视图中哪一个更适合实现以下布局: 绿色多边形是(可单击的)图像 我目前正在尝试使用包含不同TableRows的TableLayout,具体取决于行。但是,我担心这个解决方案不能有效地运行于大量图像。一个TableLayout就足够了,并且可以在许多设备上进行良好的扩展。但是,请记住,TableLayo

我正在尝试构建一个视图,该视图显示一组被1或2列分割的图像。因此,列的数量和宽度可能会有所不同

我已经查看了现有的视图,但没有一个视图能够满足我的要求

它是否已经存在,或者当前存在的android视图中哪一个更适合实现以下布局:

绿色多边形是(可单击的)图像


我目前正在尝试使用包含不同TableRows的TableLayout,具体取决于行。但是,我担心这个解决方案不能有效地运行于大量图像。

一个TableLayout就足够了,并且可以在许多设备上进行良好的扩展。但是,请记住,TableLayout是不可滚动的,因此如果您希望它可滚动(我建议在用户屏幕分辨率非常低的情况下),请使用。。下面是你可以玩的骷髅。它由3行2列组成。第一行和第二行的图片比例为50/50,最后一行的图片包含整行。。使用布局权重使其包含更多空间。在行中的第一个图像上放置布局权重2,在第二个图像上放置布局权重1,将为第一个图像分配更多空间

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scrollbars="none"
    android:layout_weight="1">

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/white"
            android:layout_margin="10dp" 
            >

            <TableRow
                android:id="@+id/tableRow1"
                android:layout_width="match_parent" 
                android:layout_height="wrap_content"

                >

                <ImageButton
                    android:contentDescription="@string/starting_content_lessions"
                    android:id="YourId"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="YourLocation"
                    android:background="YourBackground"
                    android:layout_weight="1"  /> <!-- Puting this on both items in the row makes it stretch the whole lenth -->

                <ImageButton
                    android:contentDescription="xxx"
                    android:id="xxxx"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="xxx"
                    android:background="@drawable/custom_button"
                    android:layout_weight="1"  />

            </TableRow>

            <TableRow
                android:id="@+id/tableRow2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <ImageButton
                    android:contentDescription="xxxx"
                    android:id="xxx"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="xxx"
                    android:background="@drawable/custom_button" 
                    android:layout_weight="1"  />

                <ImageButton
                    android:id="xxx"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="xxx"
                    android:contentDescription="xxx"
                    android:src="xxx" 
                    android:layout_weight="1" />

            </TableRow>

            <TableRow>
               <ImageButton
                   android:id="@+id/imageButton1"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:src="xxx" />
            </TableRow>

        </TableLayout>

</ScrollView>

谢谢,这基本上就是我目前编写的代码。我只是想从社区中了解一些关于大列表(如滚动)效率的信息,如果还有其他更好的选择,请尝试