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?
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With