Search code examples
androidkotlinonclicklistenerandroid-constraintlayout

Set onClickListener For Whole Screen


Hello Iam Fairly New To Kotlin

I Heard That You Can Set onClickListener for the whole screen in java.

so I was asking

1-Can You Do the same thing in kotlin?

2-How to set onClickListener for constraint-layout in kotlin?

and thanks in advance


Solution

  • Set click listener to whole screen

    findViewById<View>(android.R.id.content).rootView.setOnClickListener{
            // do something here
        }