Get root view from current activity

后端 未结 12 2043
不知归路
不知归路 2020-11-22 09:18

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

12条回答
  •  忘了有多久
    2020-11-22 09:57

    I tested this in android 4.0.3, only:

    getWindow().getDecorView().getRootView()
    

    give the same view what we get from

    anyview.getRootView();
    
    com.android.internal.policy.impl.PhoneWindow$DecorView@#########
    

    and

    getWindow().getDecorView().findViewById(android.R.id.content)
    

    giving child of its

    android.widget.FrameLayout@#######
    

    Please confirm.

提交回复
热议问题