I am writing an application where need to implement Google Play Store Scrolling implementation. There are sample library available to implement it, like
additional I need to implement some extra effect here.
So like mention here there are three View available in screen. (Image A)
- View A: Top Bar, will be of fix height
- View B: Fix size block that will contain some text information.
- View C: Scroll View (Expandable)
Here all I need same Parallax effect(like supported library),
- but instead to scroll completely(View A, B, C) I just wanted to scroll till View-A not gone from picture.(Image B)
- and then it should allow to scroll only View C which is list. Means now View B should remain on same position, until start scroll back down (with view A)(Image 3).
Any suggestion here ?
EDIT: Update on work I have done I am able to achieve some how this using kmshack solution but with little bit hack. Since scrolling only allow when list view have enough child to scroll so I have added some empty view and manage in Adapter.getView.
But this is not complete solution, since there are possibility that application List will not have any item to show and here also scrolling should work. Is there any way to make it possible without adding fake child?
There's many ways to do this, but basically: in your main scrollable view, leave 2 spaces for A and B but have them outside of the scrollable view, then listen to the scroll events and translate and/or transform A and B correspondingly.
The same applies to any kind of parallax effect, you simply translate in a "non linear" way giving the illusion of depth.
For some examples you can check out this G+ post by Roman Nurik.
A few tricks:
View
.getViewTreeObserver()
.addOnGlobalLayoutListener()
View.setY()
and/orView.setTranslationY()
in addition toView.setLayerType()
with typeLAYER_TYPE_HARDWARE
orLAYER_TYPE_SOFTWARE
: it will save a bitmap of your view and move it around without re-drawing it every time, but updating the view will be more expensive, so use it with consideration (maybe only during the scroll).