“浮动”查看可滚动容器内部
我想知道是否可以在 Android 上实现这种行为。
黑色方块是屏幕边界。 蓝色方块是一些放置在大可滚动容器内的父级(图中未显示)。 红色方块是儿童视图。
我对在父视图滚动期间子视图的非常特殊的垂直定位感兴趣。
子视图应该是:
- 如果父视图滚动到屏幕顶部下方,则附加到父视图的顶部(图 1);
- 如果父视图的顶部滚动到屏幕上方,则附加到屏幕的顶部,但子视图的可见部分仍有足够的空间 父级(图 3)附加到父级的底部。
- 如果父级的顶部滚动到屏幕上方并且父级的可见部分没有足够的空间(图 4),则将
I was wondering if it is possible to implement such behavior on Android.
Black square is screen bounds.
Blue square is some parent placed inside big scrollable container (not shown on the picture).
Red square is child view.
I'm interested in very special vertical positioning of the child view during scrolling of the parent.
Child view should be:
- attached to the parent's top if it is scrolled below the top of the screen (pictures 1 and
- attached to the screen's top if parent's top is scrolled above the screen but there is still enought place for child view in visible part of the parent. (picture 3)
- attached to the parent's bottom if parent's top is scrolled above the screen and there is not enought place for child view in visible part of the parent. (picture 4)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为 android 没有任何简单的方法来执行此操作,但您可以使用
RelativeLayout
作为浮动对象的父级来实现此目的,并自行控制其填充。I think android has not any straightforward method for doing this, but you can do this with using
RelativeLayout
as parent for floating object, and control its padding by yourself.