Logo Icon Logo
A Crowd-sourced Cookbook on Writing Great Android® Apps
GitHub logo Twitter logo OReilly Book Cover Art
Prevent flickering when user performs scrolling on a viewBack to Android Cookbook Home | Up to Chapter: Graphical User Interface

Author: Colin Wilcox ('NavaronUK')
In Published Edition? No
FormatLanguage: WikiFormat

Prevent flickering when user performs scrolling on a view


How annoying is it when you have created a view only to find screen flicking causes the display to flick vertically before being readjusted


Implement your Activity and override the OnTouchListener method such

public class TestActivity extends Activity implements OnTouchListener

then override the method below


public boolean onTouch(View aView, MotionEvent aEvent)
   if(aEvent.getAction() == MotionEvent.ACTION_MOVE)
           return true; 
   return false; 


The implementation capture the flick up/down event and prevents it being handled by the base activity classes. causing the view to be static as required

See Also