How to create an AsymmetricGridView with different image sizes in a row

I do a lot of google and found a lot of examples and also research this, but ~ I want a AsymmetricGridViewdifferent number of images and different image sizes in my grid.

Below are the attached images for my grid requirement.!

enter image description here

Please help me with this type of mesh or offer me a library for this type of asymmetric mesh.

Thanks in advance.

+4
source share
2 answers

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

enter image description here

+2
source

. eclipse gradle, Android Studio

build.gradle:

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

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"/>

:

@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);
}
+2

Source: https://habr.com/ru/post/1598805/


All Articles