添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
View decorView = getWindow().getDecorView();
View androidContent = findViewById(android.R.id.content);
View androidContentFirstChild = ((ViewGroup)findViewById(android.R.id.content)).getChildAt(0);
View rootView = androidContentFirstChild.getRootView();
Log.i(TAG, "decorView: " + decorView.toString());
Log.i(TAG, "androidContent: " + androidContent.toString());
Log.i(TAG, "androidContent.getParent: " + androidContent.getParent());
Log.i(TAG, "androidContentFirstChild: " + androidContentFirstChild.toString());
Log.i(TAG, "rootView: " + rootView.toString());
Log.i(TAG, "decoView.getChildCount: " + ((ViewGroup)decorView).getChildCount());
Log.i(TAG, "androidContent.getChildCount: " + ((ViewGroup)androidContent).getChildCount());
 
  • decorView 与 rootView 是一个东西,都是页面的最顶层根布局,它有且仅有一个子视图
  • android.R.id.content 是一个 FrameLayout,里面才是我们在 layout 里面写的 xml 布局
  • Android Studio 查看布局结构

    Tools ——> Layout Inspector,打开布局检查器对话框
    在这里插入图片描述
    注意,这里只有 debug 版本的 app 才可以查看布局的(第三方APP是无法查看的)
    在这里插入图片描述
    视图树

  • 最顶层是 DecorView,其下是一个 LinearLayout,包含了一个惰性布局的 ActionBar 和 FrameLayout 容器
  • 自带的 FrameLayout 的 id 固定为 android:id="@android:id/content",它的子布局才是我们在 xml 里面写的布局
    在这里插入图片描述
  • 文章来源: blog.csdn.net,作者:福州-司马懿,版权归原作者所有,如需转载,请联系作者。

    原文链接:blog.csdn.net/chy555chy/article/details/107362236

    华为开发者空间发布

    让每位开发者拥有一台云主机