1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
   | public boolean dispatchTouchEvent(MotionEvent ev) {         ViewGroup v =(ViewGroup) getWindow().getDecorView().findViewById(android.R.id.content);         Log.d(TAG, "start");         SearchView(v.getChildAt(0), ev);         return true;     }
      public void SearchView(View view ,MotionEvent ev){         View v = null ;         if( isInView(view , ev) && view.getVisibility() == View.VISIBLE){             if(view instanceof ViewGroup){                 Log.d(TAG, "in view group");                 ViewGroup group =(ViewGroup)view;                 Log.d(TAG,"child count"+group.getChildCount());                 for(int i = group.getChildCount()-1 ; i>=0 ; i--){                     Log.d(TAG,""+i);                     View child = group.getChildAt(i);                     if(child instanceof  Button){                         Log.d(TAG,"button");                     }                     if(child instanceof  TextView){                         Log.d(TAG,child.getClass().toString());                         if(child.getClass().toString().contains("TextView")){                             Log.d(TAG,"textview2");                         }else {                             Log.d(TAG, "button2");                         }                     }                     SearchView(child ,ev);
                  }             }             v = view ;         }     }
 
      public boolean isInView(View view , MotionEvent ev){         float clickX = ev.getRawX();         float clickY = ev.getRawY();         Log.d(TAG, "event x "+clickX+" y "+clickY);         int[] location = new int[2];         view.getLocationOnScreen(location);         int x = location[0];         int y = location[1];         Log.d(TAG, "view x "+x+" y "+y);         int width = view.getWidth() ;         int height = view.getHeight() ;         Log.d(TAG, "width "+width + "height "+height);         if( (clickX > x  && clickX < (x+width) )){             if(clickY >y && clickY <(y+height)) {                 return true;             }         }         return  false ;     }
  |