我需要像这样在 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>
关于android Gridview 移动一列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25645189/