1

In my application, I have a Linear layout with 10 images. I want to get the name of Imageview when touch move from one Imageview to another.

   Menu.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {

            switch(motionEvent.getAction()) {
               case MotionEvent.ACTION_MOVE:

               Float Ypoints = motionEvent.getY();
               return true;

               case MotionEvent.ACTION_DOWN:
               return true;
                default:
                    return false;
            }}
    });

I am trying to get the co-ordinate of all Imageview to get achieve this. But it will create problem for different resolutions. Is there any way to detect the view when finger touch move. Please help. Thanks.

pradip_android
  • 283
  • 1
  • 3
  • 16
  • Please clarify something for me, are you asking how to retrieve the "ID"of the view on touch? – RamithDR Sep 12 '16 at 09:37
  • I have 10 images in layout, I want to get id of particular imageview when finger touch moving. Means when touch moves without lifting finger from one image to another. – pradip_android Sep 12 '16 at 09:45
  • @RamithDR Motion touch – pradip_android Sep 12 '16 at 09:46
  • 1
    Call view.getId() inside your onTouch method. https://developer.android.com/reference/android/view/View.html#getId() – RamithDR Sep 12 '16 at 09:46
  • Hi @RamithDR , I have tried to get id but getting only one id. It is not changing whileI move my finger touch to another Imageview without lifting finger. I have already added touchListener to all imageview. But still first touch view id getting on all view. – pradip_android Sep 12 '16 at 10:19
  • Oh, for that you need to handle hit detection manually to find which view the touch is currently over. Check here : http://stackoverflow.com/questions/15595220/android-get-view-only-on-which-touch-was-released?rq=1 – RamithDR Sep 12 '16 at 10:43

0 Answers0