今天就跟大家聊聊有关深入浅析Android中DecorView与ViewRootImpl的区别,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。从setContentView说起一般地,
今天就跟大家聊聊有关深入浅析Android中DecorView与ViewRootImpl的区别,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
从setContentView说起
一般地,我们在Activity中,会在onCreate()方法中写下这样一句:
setContentView(R.layout.main);
显然,这是为activity设置一个我们定义好的main.xml布局,我们跟踪一下源码,看看这个方法是怎样做的,Activity#setContentView:
public void setContentView(@LayoutRes int layoutResID) { getWindow().setContentView(layoutResID); //调用getWindow方法,返回mWindow initWindowDecorActionBar();}...public Window getWindow() { return mWindow;}
--结束END--
本文标题: 深入浅析Android中DecorView与ViewRootImpl的区别
本文链接: https://www.lsjlt.com/news/225576.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0