Issue
How can I get the access to root view like in Java, for example:
I know using kotlin extensions we do not need to use findViewById anymore, but I do not know how to handle it. Thank you for any help.
final ViewGroup viewGroup =
(ViewGroup) ((ViewGroup)findViewById(android.R.id.content)).getChildAt(0);
if (viewGroup instanceof ConstraintLayout) {
// some logic code
}
Solution
You can also access rootView like this
View rootView = getWindow().getDecorView().getRootView();
So in koltin
val rootView = window.decorView.rootView
Answered By - Prithvi Bhola
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.