I want to make my background Activity
a little bit smaller while opening the Navigation Drawer
, Simulate the effect that exists in the Airbnb
application. I guess the best explanation would be a screenshot:
But the point is not to make the View just smaller, but to make it an animation that is synchronized to the Drawer Open/Close animation. So if you started to open the Drawer an in the middle decided to stop and go back, the background Activity scale will be affected accordingly.
How can this be done using the build in DrawerLayout? Is there some implementation for this?
You can perform this effect using the ActionBarDrawerToggle in the support library v4.
All you have to do is to Override onDrawerSlide method to retrieve the opening % of the drawer menu, and then scale your FrameLayout where your fragment is placed in.
Example with code:
main_layout.xml
Now in your Activity which holds the Drawer:
Note that i use 2 different methods to scale, because setScaleX/Y are not available in PRE - Honeycomb Android versions.
With this, you can set your own scaleFactor (i think 0.9f its small enough) or maybe try new effects (change color) based on the opening % of the drawer.
Hope it helps.
if you have a look at the third-party library SlidingMenu, that should have everything you want.
The bit you are interested in is the
behindScrollScale
, which says this:Hey you can also give best effect for smaller activity . Check ResideMenu
demo with library.