如何在行中创建具有不同图像大小的AsymmetricGridView [英] How to create AsymmetricGridView with different image sizes in row

查看:220
本文介绍了如何在行中创建具有不同图像大小的AsymmetricGridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了大量的谷歌,并找到了很多例子,并探讨了这一点,但我希望 AsymmetricGridView 不同的图像和不同的图像大小在我的网格中。



请在下面附上图片以查看我的网格要求。



请帮我申请这种类型的网格,或者建议我为这种类型的非对称网格建立库。



提前致谢。



在您的build.gradle文件中:

 依赖关系{
compile'c​​om.felipecsl.asymmetricgridv iew:library:2.0.1'
}

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

在您的活动课程中:

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

//选择您自己的首选列宽
listView.setRequestedColumnWidth(Utils.dpToPx(this,120));
final List< AsymmetricItem> items = new ArrayList<>();

//初始化你的items数组
adapter = new ListAdapter(this,listView,items);
AsymmetricGridViewAdapter asymmetricAdapter =
AsymmetricGridViewAdapter<>(this,listView,adapter);
listView.setAdapter(asymmetricAdapter);
}


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.!

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

Thanks in advance.

解决方案

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);
}

这篇关于如何在行中创建具有不同图像大小的AsymmetricGridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆