search

Home  >  Q&A  >  body text

java - Android 实现recyclerview嵌套瀑布流的效果 类似足记广场方案

最进产品有个需求 需要做一个类似于足记广场一样的界面布局

在开发过程中发现 底部的瀑布流可以通过recyclerview实现
或者使用第三方AndroidStaggeredGrid
https://github.com/etsy/AndroidStaggeredGrid
但是外部已经是一个recyclerview 嵌套的时候发现有无法显示以及触控问题

之后我反编译了它的app发现这个布局是通过一个线性布局嵌套两个
frameLayout 但是具体还是摸不清个所以然

所以我想问下各位有什么好的方案 或者 是开发建议

大家讲道理大家讲道理2892 days ago437

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-04-18 09:17:57

    This problem has been temporarily solved
    The solution is as follows:
    1. Set the layout scheme of recyclerview to StaggeredGridLayout waterfall flow layout

    StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
            mRecyclerView.setLayoutManager(layoutManager);

    2. For layouts that require a single line at the top, set Span to a single line by the following method

    private void setFullColum(RecyclerView.ViewHolder viewHolder) {
            StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams)
                    viewHolder.itemView.getLayoutParams();
            layoutParams.setFullSpan(true);
        }

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 09:17:57

    The main body is written in recycle. Then make a listview that displays all the information and put it at the head of the recycleview

    reply
    0
  • Cancelreply