Posts

Showing posts from March, 2017

How to control scrolling of your android app from volume button ?

Many times users want to operate their mobile only with a single hand, particularly in reading app. In all such scenario, a very useful feature is to scroll using volume buttons of device i.e volume up for scrolling upwards and press volume down to scroll down the reading content or any scrollable Android  view. In this post we will explore how to achieve this feature. this post assumes you know how to create the new project in the android studio. In Android most widely used scrollable view are  NestedScrollView , ScrollView , RecyclerView and ListView . we will start with NestedScrollView. Sample app Available on github.com. Implement following method in your activity... onKeyDown( int  keyCode, KeyEvent event) onKeyUp( int keyCode, KeyEvent event) onKeyLongPress( int keyCode, KeyEvent event)  In keyDown, we have to do nothing special if it's a Volume UP or Volume Down Key Event then start tracking your event for the corresponding key u...