How do I detect touch input on the Android

前端 未结 5 1489
無奈伤痛
無奈伤痛 2020-12-05 11:18

Right now all I am trying to do is detect when the screen is pressed and then display a log message to confirm it happened. My code so far is modified off of the CameraPrevi

5条回答
  •  醉酒成梦
    2020-12-05 11:57

    //on finger touch view visible. On finger up gone

        hintView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
              if(event.getAction()==MotionEvent.ACTION_MOVE){
                    hintText.setVisibility(View.VISIBLE);
                }else if(event.getAction()==MotionEvent.ACTION_UP){
                  hintText.setVisibility(View.GONE);
    
                }
    
                return true;
            }
        });
    

提交回复
热议问题