eswaat
eswaat

Reputation: 763

Android make a screen disable or unclickable

I want to make my android activity unclickable. I have tried Enable/disable an activity programatically but it's not working for me.

I also tried to get relative layout disable but it is not working.

Is there any other ways for making and android activity(full) unclickable?

Upvotes: 1

Views: 5882

Answers (3)

Aswin Rajendiran
Aswin Rajendiran

Reputation: 3409

You can create a fake transparent view which takes up with whole screen and place it on top of all views.

private boolean shouldBlockTouches = false;

fakeView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return shouldBlockTouches;
        }
    });

set the shouldBlockTouches where ever you please.

Upvotes: 3

Manmohan Badaya
Manmohan Badaya

Reputation: 2336

I think u can try by applying onClick on root layout and do nothing.tou can do this as well if u want activity unclickable then doesn't provide any beahvior will tend to do nothing.

Upvotes: 0

bo malone
bo malone

Reputation: 178

You could set every view as unclickable in the XML:

android:clickable="false"

Upvotes: 2

Related Questions