Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Enable click event on empty activity area

i set my activity theme to translucent so as to see through to the underneath activity window.

I want to know if it's possible to enable click event when user tap on empty area on this translucent activity?

Thanks,

dara kok

like image 625
dara kok Avatar asked Apr 27 '26 10:04

dara kok


1 Answers

It is possible to add click event to your activity. You need to do as below:

You could have done setContentView(R.layout.main); in onCreate() of your activity.

In main.xml, give some id to the root layout. For eg.,

Lets consider you have root as LinearLayout with id set as below,

Then in onCreate() of your activity, you will have to do the following:

LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);
layout.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

        }
    });
like image 72
Swathi EP Avatar answered Apr 29 '26 23:04

Swathi EP



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!