I know how to get the root view with View.getRootView(). I am also able to get the view from a button\'s onClick
event where the argument is a View. But how can
Use this to simplify access in an Activity. Then you can directly refer to rootView
from the Activity, or activity.rootView
outside of it:
val Activity.rootView get() = window.decorView.rootView
If you'd like to add the same for Fragments for consistency, add:
val Fragment.rootView get() = view?.rootView