Don't collapse Toolbar when RecyclerView fits the screen

前端 未结 10 1521
陌清茗
陌清茗 2020-11-30 21:08


I\'ve made an app using Android Design Library, with a Toolbar and TabLayout.
Actually 2 tabs are present, both with 2 RecyclerView, that automati

10条回答
  •  情书的邮戳
    2020-11-30 21:18

    You can check if the last item in RecyclerView is visible. If it's not then turn off scrolling programmatically using this method:

                //turn off scrolling
                AppBarLayout.LayoutParams toolbarLayoutParams = (AppBarLayout.LayoutParams) mToolbar.getLayoutParams();
                toolbarLayoutParams.setScrollFlags(0);
                mToolbar.setLayoutParams(toolbarLayoutParams);
    
                CoordinatorLayout.LayoutParams appBarLayoutParams = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
                appBarLayoutParams.setBehavior(null);
                appBarLayout.setLayoutParams(appBarLayoutParams);
    

提交回复
热议问题