"Floating" view inside scrollable container
I was wondering if it is possible to implement such behavior on Android.
Bla开发者_运维技巧ck 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)
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.
精彩评论