首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NestedScrollView修复NestedScrollView内部的视图顶部

NestedScrollView修复NestedScrollView内部的视图顶部
EN

Stack Overflow用户
提问于 2019-12-05 07:46:24
回答 2查看 547关注 0票数 1

我想修复的TabLayout在顶部滚动时,像Instagram。在NestedScrollView中有什么方法可以做到这一点吗

代码语言:javascript
复制
NestedScrollView
-- ConstraintLayout
---- OtherViews
---- TabLayout
---- ViewPager

https://i.imgur.com/G5QcqaW.png

https://gist.github.com/buraktabn/c73cd04bed6a223471834756d6f32773

EN

回答 2

Stack Overflow用户

发布于 2019-12-05 08:57:13

你可以这样做吗:

代码语言:javascript
复制
ConstraintLayout
-- OtherViews
-- TabLayout
-- NestedScrollView
---- ViewPager

这样ViewPager的内容就会滚动吗?仅供参考,CoordinatorLayoutCollapsingToolbarLayout (https://material.io/develop/android/components/collapsing-toolbar-layout/)可能也值得一看,它允许用户在向上滚动时重新获得一些屏幕。

票数 0
EN

Stack Overflow用户

发布于 2019-12-05 09:12:04

您不能直接在NestedScrollView中执行此操作,因为视图本身应该滚动内容。

如果您正在寻找顶部固定不动的TabLayout,您可以将TabLayoutNestedScrollView中拉出,并将这两个视图包含在另一种布局类型下(例如。LinearLayoutConstraintLayout等)。

如果你想要一个随着用户滚动而展开和收缩的TabLayout,你最好的选择是一个CoordinatorLayout,它可以包含一个NestedScrollView,然后在CoordinatorLayoutAppBarLayout/CollapsingtoolbarLayout下实现你的TabLayout

代码语言:javascript
复制
CoordinatorLayout
- AppBarLayout
-- CollapsingToolbarLayout
--- [Your implementation of the `TabLayout`]
-- NestedScrollView

您可以在此处找到有关CoordinatorLayoutCollapsingToolbarLayout的更多信息:

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59186199

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档