5

In my application i am trying to make my gridview asymmetric,but i am able to set only with colums 2 or 3 so on..any other option to make gridview asymmetric? following is my code for gridview,can anyone help me with this?

<?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>

what i want:

enter image description here

Aditya
  • 1,508
  • 1
  • 19
  • 37
  • Use a `GridLayout`, instead of a `GridView`. Example: http://code.tutsplus.com/tutorials/android-user-interface-design-creating-a-numeric-keypad-with-gridlayout--mobile-8677 – Phantômaxx Jul 11 '15 at 07:05
  • then how you display parsed json response on individual items?? – Aditya Jul 11 '15 at 07:34

1 Answers1

0

Nothing to do with all these.... Just copy this inside your getView method in adapter...

    if (position % 2 == 1) {    
     holder.testbtn.setVisibility(View.VISIBLE);    
     } else {
        holder.testbtn.setVisibility(View.GONE);
     }
kiturk3
  • 549
  • 10
  • 30