Adi*_*tya 5 android android-gridview
在我的应用程序中,我试图使我的 gridview 不对称,但我只能设置 2 或 3 列等等……还有其他选项可以使 gridview 不对称吗?以下是我的 gridview 代码,有人可以帮我吗?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F3F3F3"
>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="150dp"
/>
<GridView
android:numColumns="2"
android:gravity="center"
android:stretchMode="columnWidth"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/allproduct_grid"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp"
android:layout_marginTop="10dp"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我想要的是:

与所有这些无关...只需将其复制到适配器中的 getView 方法中...
if (position % 2 == 1) {
holder.testbtn.setVisibility(View.VISIBLE);
} else {
holder.testbtn.setVisibility(View.GONE);
}
Run Code Online (Sandbox Code Playgroud)