gpt4 book ai didi

android - 如何停止折叠工具栏滚动取决于 RecyclerView 列表计数

转载 作者:行者123 更新时间:2023-12-05 07:49:13 25 4
gpt4 key购买 nike

在我的应用程序中,我使用的是 Activity 和 Fragment。Collapsing ToolBar 在 Activity 中,而 RecyclerView 在 Fragment 中。

我附上了两张图片。* 滚动前* 滚动后项目上升。因此在底部创建了一个空白空间。

如果 recyclerview 那里有可见项目,我需要停止折叠。如果项目更多,则必须启用滚动。如何做到这一点?请帮忙。甚至我也提到了以下链接。但是没有Activity & Fragment Collapsing ToolBar滚动的组合。

How to disable scrolling of NestedScrollView&CollapsingToolbarLayout, for example when there is no more content below?

enter image description here

最佳答案

创建 AppBar 布局 public in activity and in fragment according to recycle view count set expand like this

               int itemCount=adapter.size();
if(itemCount>4){
((YourActivity)getActivity()).appBarLayout.setExpanded(true,true);
}else{
((YourActivity)getActivity()).appBarLayout.setExpanded(false,true);
}

adapter.size() 指的是你的recycleview 适配器数

关于android - 如何停止折叠工具栏滚动取决于 RecyclerView 列表计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37671660/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com