【问题标题】:Recycle-view different column number循环查看不同的列号
【发布时间】:2018-06-12 10:41:45
【问题描述】:

你好,我可以用回收视图布局管理器制作这样的图像吗? 这张图片显示了我想要做的事情提前谢谢。

【问题讨论】:

  • 进一步澄清...你可以问我..
  • @SantanuSur 谢谢你,但你能给出一个简单的代码
  • Dynamic Grid Layout的可能重复

标签: java android


【解决方案1】:

使用ReycyleView 使用GridLayoutManager

manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
    if (position == 0) {
        return 2; //  Splitting into 2 columns
    } else {
        return 3; // Splitting into 3 columns
    }
}

});

【讨论】:

    【解决方案2】:

    是的,你可以...在recycler_adapter 中检查position == 0 是否有两个cardview visible 并设置它们...并在else {cardview4 ,cardview5,cardview6 visible 中设置它们并使cardview1 和cardview2 Gone 膨胀布局将包含一个相对纬度 你有两个horizontal linearlayouts 只是hide make the layouts gone and visible at proper position in onBind()

    【讨论】:

      【解决方案3】:

      为了实现这一观点,我认为GridLayoutManager 与它的setSpanSizeLookup() 方法是最佳选择。您可以在this answer 中找到完整的解释。如果您在实施过程中遇到任何问题,可以询问。

      【讨论】:

      • 我该如何实现 // RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(this,2);
      • 能否请您详细说明您的问题,以便我可以解决您的问题……我不明白您的意思。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-20
      • 1970-01-01
      • 1970-01-01
      • 2015-04-14
      • 1970-01-01
      • 1970-01-01
      • 2021-07-13
      相关资源
      最近更新 更多