android Gridview将一列移动

android Gridview将一列移动,android,gridview,shift,Android,Gridview,Shift,我需要在gridview中实现移位列,如下所示 但只有两列。 我曾尝试在适配器中使用两种不同的类型,但它并没有解决我的任务 在我看来,我将不得不扩展gridview和ovverride onDraw方法,但可能已经存在另一个解决方案或库 这可以通过布局XML文件完成 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" a

我需要在gridview中实现移位列,如下所示

但只有两列。 我曾尝试在适配器中使用两种不同的类型,但它并没有解决我的任务


在我看来,我将不得不扩展gridview和ovverride onDraw方法,但可能已经存在另一个解决方案或库

这可以通过布局XML文件完成

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<LinearLayout
    android:id="@+id/header"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:padding="5dp" >

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
      />

</LinearLayout>

<GridView
    android:id="@+id/grid"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@id/header"
    android:cacheColorHint="#0000"
    android:columnWidth="100dp"
    android:horizontalSpacing="5dp"        
    android:numColumns="2"
    android:stretchMode="columnWidth"
    android:verticalSpacing="5dp" />

</RelativeLayout>

使用
网格布局
。它允许非均匀网格。通过导入支持库,它也可以在旧设备上使用。