1

我有显示来自 JSON 的图像的 GridView

[图片]

在此处输入图像描述

我用于网格视图的 xml 是::

restaurant_desc_photos.xml

<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/listview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:numColumns="auto_fit"
    android:columnWidth="90dp"
    android:horizontalSpacing="10dp"
    android:verticalSpacing="10dp"
    android:gravity="center"
    android:stretchMode="columnWidth" >  

</GridView>

grid_view_image.xml

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

    <ImageView
        android:id="@+id/flag"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:background="#000000"
        android:padding="1dp" />

</RelativeLayout>

如何进行更改,以便我可以将我的输出反映为::

在此处输入图像描述

水平滚动在这里也很重要

有任何想法吗

谢谢

4

1 回答 1

1

唯一的方法是使用两种方式网格视图库使用以下链接库 https://github.com/jess-anders/two-way-gridview

1)将该库添加到项目中

2) 在 xml 布局中相应地更改包名称,您将在其中插入水平滚动视图片段:

   <com.future.android.app.library.slidinggridview.TwoWayGridView
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@id/fragment_product_twgv_grid"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginLeft="5dp"
    android:visibility="gone"
    app:cacheColorHint="#ffe8e8e8"
    app:columnWidth="300dp"
    app:horizontalSpacing="10.0dip"
    app:numColumns="auto_fit"
    app:numRows="2"
    app:rowHeight="290dp"
    android:fastScrollEnabled="true"
    app:scrollDirectionLandscape="horizontal"
    app:scrollDirectionPortrait="vertical"
    app:stretchMode="spacingWidthUniform"
    app:verticalSpacing="10.0dip" />

您可以相应地设置列数以及宽度和高度。

于 2013-10-01T05:42:13.497 回答