首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏算法微时光

    Android之RecyclerView的StaggeredGridLayoutManager使用

    image.png StaggeredGridLayoutManager StaggeredGridLayoutManager(瀑布流布局效果),是配合RecyclerView使用的。 androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.StaggeredGridLayoutManager java.util.ArrayList; public class MainActivity extends AppCompatActivity { RecyclerView mRecyclerView; StaggeredGridLayoutManager RecyclerView) findViewById(R.id.recyclerView); int spanCount = 5; mLayoutManager = new StaggeredGridLayoutManager ( spanCount, StaggeredGridLayoutManager.VERTICAL); mRecyclerView.setLayoutManager

    4.4K21发布于 2020-12-07
  • 来自专栏韩曙亮的移动开发专栏

    【RecyclerView】 五、RecyclerView 布局 ( 瀑布流 | 交错网格局管理器 StaggeredGridLayoutManager )

    文章目录 一、交错网格局管理器 StaggeredGridLayoutManager ( 瀑布流 ) 二、交错网格局管理器默认设置 三、交错网格局管理器水平方向设置 四、完整代码示例 五、RecyclerView ( 瀑布流 ) ---- 使用代码创建 交错网格局管理器 StaggeredGridLayoutManager, 推荐使用 StaggeredGridLayoutManager(int spanCount 创建并设置布局管理器 //创建布局管理器 StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager 创建并设置布局管理器 //创建布局管理器 /*StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager 创建并设置布局管理器 //创建布局管理器 /*StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager

    2.8K00编辑于 2023-03-28
  • 来自专栏胡飞洋的Android进阶

    曝光埋点方案:recyclerView中的item曝光逻辑实现

    ) { StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager ) manager; range = findRangeStaggeredGrid(staggeredGridLayoutManager); orientation = staggeredGridLayoutManager.getOrientation(); } if (range == null ) { StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager orientation = staggeredGridLayoutManager.getOrientation(); } if (range == null

    6.4K10发布于 2020-07-23
  • 来自专栏BennuCTech

    实现一个带有header和footer功能的RecyclerView

    ) { StaggeredGridLayoutManager.LayoutParams headerParams = new StaggeredGridLayoutManager.LayoutParams ){ return ((StaggeredGridLayoutManager) layout).getOrientation() == StaggeredGridLayoutManager.VERTICAL ){ return ((StaggeredGridLayoutManager) layout).getSpanCount(); } 普通的item,由于需要判断是否是一行的最后一个isEnd(在GridLayoutManager或StaggeredGridLayoutManager中),所以要排除掉header对item位置的影响, ){ int[] positions = ((StaggeredGridLayoutManager) layoutManager).findLastVisibleItemPositions

    2.4K20编辑于 2021-12-17
  • 来自专栏向治洪

    解决Scrollview 嵌套recyclerview不能显示,高度不正常的问题

    ) { spanCount = ((StaggeredGridLayoutManager) layoutManager) .getSpanCount ) { int orientation = ((StaggeredGridLayoutManager) layoutManager) .getOrientation (); if (orientation == StaggeredGridLayoutManager.VERTICAL) { if ((pos + ) { int orientation = ((StaggeredGridLayoutManager) layoutManager) .getOrientation (); // StaggeredGridLayoutManager 且纵向滚动 if (orientation == StaggeredGridLayoutManager.VERTICAL

    4.2K50发布于 2018-02-05
  • 来自专栏该溜子的专栏

    【Android】网络布局 && 瀑布流布局

    RecyclerView recyclerView = findViewById(R.id.recycler_view); //设置瀑布流布局管理器 StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL ); recyclerView.setLayoutManager(staggeredGridLayoutManager); ArrayList<Integer> data (); 第一个参数2,表示有两列 第二个参数表示垂直滚动 //设置瀑布流布局管理器 StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); 六:StaggeredGridAdapter

    44510编辑于 2025-08-21
  • 来自专栏风吹杨柳

    Android RecyclerView 使用完全解析 体验艺术般的控件

    ) { spanCount = ((StaggeredGridLayoutManager) layoutManager) .getOrientation(); // StaggeredGridLayoutManager 且纵向滚动 if (orientation == StaggeredGridLayoutManager.VERTICAL (4, StaggeredGridLayoutManager.VERTICAL)); 这两种写法显示的效果是一致的,但是注意StaggeredGridLayoutManager构造的第二个参数传一个 orientation,如果传入的是StaggeredGridLayoutManager.VERTICAL代表有多少列;那么传入的如果是StaggeredGridLayoutManager.HORIZONTAL 就代表有多少行,比如本例如果改为: mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(4, StaggeredGridLayoutManager.HORIZONTAL

    1.9K10发布于 2019-07-08
  • 来自专栏Android开发与分享

    【Android】RecyclerView的使用

    layoutManager1 = new GridLayoutManager(this, arrayNum); 或瀑布流() int arrayNum = 2;//GridView样式时的列数 int style = StaggeredGridLayoutManager.VERTICAL ;//列垂直排布 StaggeredGridLayoutManager layoutManager1 = new StaggeredGridLayoutManager(arrayNum,style);

    1.6K50发布于 2018-05-18
  • 来自专栏BennuCTech

    为RecyclerView添加下拉刷新功能

    GridLayoutManager) layoutManager).findFirstVisibleItemPosition(); } if(layoutManager instanceof StaggeredGridLayoutManager ){ int[] positions = ((StaggeredGridLayoutManager) layoutManager).findFirstVisibleItemPositions GridLayoutManager) layoutManager).findLastVisibleItemPosition(); } if(layoutManager instanceof StaggeredGridLayoutManager ){ int[] positions = ((StaggeredGridLayoutManager) layoutManager).findLastVisibleItemPositions

    1.2K50编辑于 2021-12-29
  • 来自专栏开发者技术前线

    自定义RecyclerView打造Android TV桌面

    2.使用StaggeredGridLayoutManager实现管理,如果使用GridLayoutManager会出现焦点的错乱,当使用五向键左右移动时,会从上面转移到下面。 isFirstItemVisible() { LayoutManager layoutManager = getLayoutManager(); if (layoutManager instanceof StaggeredGridLayoutManager ) { int[] firstVisibleItems = null; firstVisibleItems = ((StaggeredGridLayoutManager allItemNum) { LayoutManager layoutManager = getLayoutManager(); if (layoutManager instanceof StaggeredGridLayoutManager ) { int[] lastVisibleItems = null; lastVisibleItems = ((StaggeredGridLayoutManager

    2.8K20发布于 2020-11-23
  • 来自专栏andy的小窝

    自定义header的RecyclerView

    = null && lp instanceof StaggeredGridLayoutManager.LayoutParams) { StaggeredGridLayoutManager.LayoutParams p = (StaggeredGridLayoutManager.LayoutParams) lp;

    78230发布于 2020-02-12
  • 来自专栏Android&Java技术

    Android RecyclerView浅析(分类型)

    参数二:指明行数(Horizontal),或列数(Vertical); 参数三:指明方向;参数四:是否倒序; 3).瀑布流布局管理器 mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager (4, StaggeredGridLayoutManager.VERTICAL)); 参数一:指明行数(Horizontal),或列数(Vertical); 参数二:指明方向; 4.给RecyclerView ###7.3StaggeredGridLayoutManager添加头部 在adapter中重写些方法 @Override public void onViewAttachedToWindow(RecyclerView.ViewHolder = null && lp instanceof StaggeredGridLayoutManager.LayoutParams) { StaggeredGridLayoutManager.LayoutParams p = (StaggeredGridLayoutManager.LayoutParams) lp; //设置全屏 p.setFullSpan(holder.getLayoutPosition

    1.4K20发布于 2020-02-27
  • 来自专栏tea9的博客

    android-viewpager-adapter

    mrefreshLayout.setRefreshViewHolder(new BGANormalRefreshViewHolder(context, true)); data_recycleview.setLayoutManager(new StaggeredGridLayoutManager (2, StaggeredGridLayoutManager.VERTICAL)); // mrefreshLayout.beginRefreshing(); //

    53230编辑于 2022-07-16
  • 来自专栏CnPengDev

    Android:流式布局实现总结

    实现流式布局的方式大致有如下五种: 自定义FlowLayout ChipGroups RecyclerView+StaggeredGridLayoutManager RecyclerView+FlexboxLayoutManager 借助StaggeredGridLayoutManager我们可以很方便的实现流式布局/标签。 我们只需要构建一个StaggeredGridLayoutManager对象,然后赋值给RecyclerView即可。 示例代码 rv_flowImpl.adapter = mStaggerAndGvAdapter rv_flowImpl.layoutManager = StaggeredGridLayoutManager 它可以实现StaggeredGridLayoutManager不能实现的自动换行效果。

    7.2K20发布于 2020-08-11
  • 来自专栏Android先生

    RecyclerView 梳理:点击&长按事件、分割线、拖曳排序、滑动删除

    ) { spanCount = ((StaggeredGridLayoutManager) layoutManager) .getSpanCount ) { int orientation = ((StaggeredGridLayoutManager) layoutManager) .getOrientation (); if (orientation == StaggeredGridLayoutManager.VERTICAL) { if ((pos + ) { int orientation = ((StaggeredGridLayoutManager) layoutManager) .getOrientation (); // StaggeredGridLayoutManager 且纵向滚动 if (orientation == StaggeredGridLayoutManager.VERTICAL

    4.2K30发布于 2018-08-07
  • 来自专栏韩曙亮的移动开发专栏

    【RecyclerView】 十四、GridLayoutManager 网格布局管理器 ( GridLayoutManager.SpanSizeLookup 指定 item 元素占用网格个数 )

    androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.StaggeredGridLayoutManager 官方文档 : https://developer.android.google.cn/reference/androidx/recyclerview/widget/LinearLayoutManager StaggeredGridLayoutManager 官方文档 : https://developer.android.google.cn/reference/androidx/recyclerview/widget/StaggeredGridLayoutManager

    2.5K00编辑于 2023-03-28
  • 来自专栏三流程序员的挣扎

    RecyclerView 使用总结

    简单使用 LinearLayoutManager 线性管理器(支持横向、纵向) GridLayoutManager 网格布局管理器 StaggeredGridLayoutManager 瀑布流式布局管理器 ) { spanCount = ((StaggeredGridLayoutManager) layoutManager) .getSpanCount ) { int orientation = ((StaggeredGridLayoutManager) layoutManager) .getOrientation (); if (orientation == StaggeredGridLayoutManager.VERTICAL) { if ((pos + (); // StaggeredGridLayoutManager 且纵向滚动 if (orientation == StaggeredGridLayoutManager.VERTICAL

    4.1K20发布于 2018-09-11
  • 来自专栏老欧说安卓

    Android开发笔记(一百二十二)循环器视图RecyclerView

    目前有三种,分别是:线性布局管理器LinearLayoutManager、网格布局管理器GridLayoutManager、瀑布流网格布局管理器StaggeredGridLayoutManager。 new DefaultItemAnimator()); rv_grid.addItemDecoration(new DividerGridItemDecoration(this)); } } StaggeredGridLayoutManager 之前我们要想实现瀑布流效果,都得自定义控件或者借助于第三方开源库如StaggeredGridView、PinterestLikeAdapterView等等;现在Android在support-v7库中推出了StaggeredGridLayoutManager 下面是StaggeredGridLayoutManager的常用方法: 构造函数 : 可指定网格的列数和方向。 setSpanCount : 单独设置网格的列数。 ; public class StaggeredActivity extends Activity { private RecyclerView rv_staggered; private StaggeredGridLayoutManager

    3.7K20发布于 2019-01-18
  • 来自专栏AndroidStudio初识

    RecyclerView详解

    2、 GridLayoutManager 网格布局管理器 3、 StaggeredGridLayoutManager 瀑布流式布局管理器 基本用法 1.引入依赖 implementation 'com.android.support *设置竖直瀑布流布局StaggeredGridLayoutManager * 这里同样还是修改设置布局管理器即可,秒秒钟的事情 ? : //设置竖直瀑布流布局 StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager( 4, StaggeredGridLayoutManager.VERTICAL); //设置布局管理器 rvView.setLayoutManager(staggeredGridLayoutManager

    3.5K21发布于 2019-09-12
  • 来自专栏Java实战博客

    Recycler Android开发

    recyclerView = findViewById(R.id.rv); // 需要自定义布局才可以使用 如:LinearLayoutManager、网格GridLayoutManager、瀑布流StaggeredGridLayoutManager LinearLayoutManager(this); // GridLayoutManager viewManager = new GridLayoutManager(this,3); StaggeredGridLayoutManager viewManager = new StaggeredGridLayoutManager(3, LinearLayout.VERTICAL); // 布局对象绑定自定义布局(不绑定就没有外观

    1K10编辑于 2022-05-09
领券