Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NavigationDrawer hint animation (like Google Currents)

I am looking for a way to give the users a hint that the navigation drawer exists.

I like the way that Google Currents hints that there is a next page, it just slides in the next page a few pixels and then removes it.

What is the best way to accomplish such an animation?

like image 666
Heinrisch Avatar asked Jul 29 '13 14:07

Heinrisch


1 Answers

This will only display a narrow bar on the left - like if you held your finger pressed on the border. Not sure if this is what Google Currents do, but I found this to be an elegant way to give a hint. Source

protected void peekDrawer() {
    long downTime = SystemClock.uptimeMillis();
    long eventTime = SystemClock.uptimeMillis() + 100;
    MotionEvent motionEvent = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, 0, 100, 0);
    m_drawerLayout.dispatchTouchEvent(motionEvent);
    motionEvent.recycle();

    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            long downTime = SystemClock.uptimeMillis();
            long eventTime = SystemClock.uptimeMillis() + 100;
            MotionEvent motionEvent = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, 0, 100, 0);
            m_drawerLayout.dispatchTouchEvent(motionEvent);
            motionEvent.recycle();
        }
    }, (long) (1 * DateUtils.SECOND_IN_MILLIS)); //change 1 to however many seconds you wish to display the hint for
}
like image 99
Voy Avatar answered Sep 21 '22 23:09

Voy