1

I have a fullscreen activity

enter image description here

I do not want this to happen. When under the status bar, the onClickListener of any view also appears.

My ImageView OnClickListener:

img.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {

        onSelectImageClick(v);

    }
});

XML:

<ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:scaleType="centerCrop"
    android:adjustViewBounds="true"
    android:id="@+id/img"
    android:src="@drawable/empty"/>
Milan Pansuriya
  • 2,521
  • 1
  • 19
  • 33
Kevin La Delfa
  • 69
  • 1
  • 10
  • check it out:- https://stackoverflow.com/questions/8200838/is-there-a-way-to-check-the-visibility-of-the-status-bar – Vishal kumar singhvi Dec 19 '18 at 18:29
  • thanks, but this does not work for me because i have a translucent status bar. – Kevin La Delfa Dec 19 '18 at 18:37
  • Hm, maybe not best solution, but: override onTouch instead of onClick, and apply following logic: on touch down, save the system time. Than on touch up, check if if just a second has passed (or check if touch coordinate change is larger then a threshold), that will indicate a simple click. You may also try following solution for click detection, altough I don't know if it will work in your case: https://stackoverflow.com/questions/19538747/how-to-use-both-ontouch-and-onclick-for-an-imagebutton. – Anhayt Ananun Dec 19 '18 at 19:13
  • Is working. Capture the coordinates by pressing and releasing the click. Then I compare them. Thanks for the help. – Kevin La Delfa Dec 19 '18 at 19:45

1 Answers1

1

I found the solution:

img.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {

            if(event.getAction() == MotionEvent.ACTION_DOWN) {

                x = event.getX();
                y = event.getY();

            } else if (event.getAction() == MotionEvent.ACTION_UP) {

                x2 = event.getX();
                y2 = event.getY();

                if(x==x2 && y==y2){



                }else{



                }

            }

            return false;
        }
    });

Thanks, Anhayt Ananun

Kevin La Delfa
  • 69
  • 1
  • 10