简体   繁体   English

仅在CoordinatorLayout中滚动时显示工具栏阴影

[英]Show Toolbar shadow only on scroll in CoordinatorLayout

I would like to know how I can use a Toolbar / CollapsingToolbarLayout in a CoordinatorLayout to show a shadow only when content is scrolled under it and not otherwise (ie after the fragment is created it should not show a shadow until the user starts scrolling down a list). 我想知道如何在CoordinatorLayout中使用工具栏/ CollapsingToolbarLayout仅在内容在其下滚动时显示阴影而不是其他方式(即在创建片段之后,它不应显示阴影,直到用户开始向下滚动列表)。 Preferably with just XML 最好只用XML

(I don't think I need a AppBarLayout here, since the size of the toolbar is fixed and does not need the resizing or parallax effects etc..) (我认为我不需要AppBarLayout,因为工具栏的大小是固定的,不需要调整大小或视差效果等。)

Any help with this is much appreciated 对此有任何帮助非常感谢

You can try setting elevation of the toolbar. 您可以尝试设置工具栏的高程。 0 elevation means no shadow. 0高程表示没有阴影。

toolbar.setElevation(int)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 工具栏不响应CoordinatorLayout中的滚动 - Toolbar not responding to scroll in CoordinatorLayout 工具栏在CoordinatorLayout中不会在滚动时折叠 - Toolbar not collapsing on scroll in CoordinatorLayout 使用CoordinatorLayout滚动隐藏工具栏 - Hide Toolbar on scroll with CoordinatorLayout Android CoordinatorLayout:仅在列表开始滚动时滚动工具栏 - Android CoordinatorLayout : ToolBar scroll only when list starts scrolling 在CoordinatorLayout上以编程方式隐藏/显示工具栏 - Hide/Show Toolbar programmatically on CoordinatorLayout 如何在CoordinatorLayout内部的工具栏上触发滚动行为 - How to Trigger a Scroll Behavior on a Toolbar inside a CoordinatorLayout 滚动时隐藏工具栏无法正常工作[CoordinatorLayout] - Hide Toolbar on scroll wont work properly [CoordinatorLayout] 向上滚动时,CoordinatorLayout + CollapsingToolbarLayout未设置工具栏 - CoordinatorLayout + CollapsingToolbarLayout not setting toolbar when scroll up CoordinatorLayout工具栏不会在回收视图滚动中隐藏 - CoordinatorLayout toolbar is not hiding on recycle view scroll CoordinatorLayout,AppBarLayout和ToolBar - 工具栏不会滚动屏幕 - CoordinatorLayout, AppBarLayout and ToolBar - Toolbar doesn't scroll off the screen
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM