英文:
Children of CollapsingToolbarLayout with different collapse modes
问题
我想创建一个包含两个视图的CollapsingToolbarLayout(一个在另一个下面 - 像LinearLayout一样)。问题是,我希望这些视图具有不同的折叠模式 - 上面的视图是视差,另一个是不折叠。
当我将它们放入一个LinearLayout中时,我只能将折叠模式设置为这个LinearLayout,所以两个视图的行为相同。
我尝试将一个视图放入一个工具栏中,这样我可以实现两种不同的折叠模式,但我不能让它们一个在另一个下面 - 我不能简单地设置一个边距,因为上面的视图具有动态高度,所以我需要某种方式进行定位。
英文:
I would like to create a CollapsingToolbarLayout that contains two views (one below the other - like a LinearLayout manner). The problem is that i would like these views to have different collapse modes - upper one parallax, the other - none.
When I put them in one LinearLayout I can only set the collapse mode to this LinearLayout, so both views behave the same.
I tried putting one view inside a Toolbar and that wat I can achieve two different collapse modes, but I cant get them to be one under the other - I can't simply set a margin because the upper view has a dynamic height so I would need some kind of anchoring.
答案1
得分: 1
考虑使用MotionLayout。您只需定义起始和结束状态(在本例中,起始状态将使两者都可见,而结束状态将使顶部一个消失,带有视差效果)。
英文:
Consider using MotionLayout. All you have to do is define the start and end states (In this case, the start state will have both of them visible, and the end state will have the top one gone with parallax effect).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论