Arvind Kanjariya
Arvind Kanjariya

Reputation: 2097

How to create AsymmetricGridView with different image sizes in row

I do lots of google and found many examples and also explore that but ~I want AsymmetricGridView different No of images and different images sizes in my grid.

Please find below attached images for my requirement of grid.!

enter image description here

Please help me for the this type of grid or suggest me library for the this type of asymmetric grid.

Thanks in advance.

Upvotes: 4

Views: 6767

Answers (2)

Anirudh Sharma
Anirudh Sharma

Reputation: 7964

You can use THIS LIBRARY to achieve your goal.Import this lib in your eclipse workspace or include in your gradle if you are using Android Studio

In your build.gradle file:

dependencies {
    compile 'com.felipecsl.asymmetricgridview:library:2.0.1'
}

In your layout xml:

<com.felipecsl.asymmetricgridview.library.widget.AsymmetricGridView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/listView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

In your activity class:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    listView = (AsymmetricGridView) findViewById(R.id.listView);

    // Choose your own preferred column width
    listView.setRequestedColumnWidth(Utils.dpToPx(this, 120));
    final List<AsymmetricItem> items = new ArrayList<>();

    // initialize your items array
    adapter = new ListAdapter(this, listView, items);
    AsymmetricGridViewAdapter asymmetricAdapter =
        new AsymmetricGridViewAdapter<>(this, listView, adapter);
    listView.setAdapter(asymmetricAdapter);
}

Upvotes: 2

Sharjeel
Sharjeel

Reputation: 15798

You can use following library https://github.com/felipecsl/AsymmetricGridView

enter image description here

Upvotes: 2

Related Questions