View,Activity,Window三者的关系

Android-Framework: Activity、Window、View三者之间的关系 Android-Framework: Activity、Window、View三者之间的关系 文章目录Android-Framework: Activity、Window、View三者之间的关系前言Window对象是什么时候创建的?总结参考 前言 Activity、View 做过Android开发的都比较熟悉一个是Android的四大组件、一个是用于展示各种控件的View,相对于前两者 Window 在日常开发中比较陌生,今天我们这篇文章就将这三个问题讲清楚。 Window对象是什么时候创建的? 要想弄清楚 阅读详情
    在Activity中,通过setContentView就可以显示xml的布局文件了,也就是把一个个View控件组合在一起,首先,这个Activity的方法setContentView有三个重载的方法。
    
public void setContentView(int layoutResID) {
        getWindow().setContentView(layoutResID);
    }
    public void setContentView(View view) {
        getWindow().setContentView(view);
    }
    public void setContentView(View view, ViewGroup.LayoutParams params) {
        getWindow().setContentView(view, params);
    }
    
    可以看出,三个方法什么也没用做,只是调用了getWindw方法。看一下getWindow方法,仅仅是
      
  public Window getWindow() {
        return mWindow;
    }

    mWindwow是在attach方法中创建的,看一看attach方法。有这两行代码
  
  mWindow = PolicyManager.makeNewWindow(this);
    mWindow.setCallback(this);

首先,看看PolicyManager.makeNewWindow(this)是如何处理的。
//通过反射的方式,创建一个Ipolicy的实例对象。
    public final class PolicyManager {  
    private static final String POLICY_IMPL_CLASS_NAME =  
        "com.android.internal.policy.impl.Policy";  
  
    private static final IPolicy sPolicy;  
  
    static {  
       // 运行时动态装载IPolicy实现类   
        try {  
           //加载Policy类的同时会执行其中的静态代码段   
            Class policyClass = Class.forName(POLICY_IMPL_CLASS_NAME);  
            sPolicy = (IPolicy)policyClass.newInstance();  
        } catch (ClassNotFoundException ex) {  
            throw new RuntimeException(  
                    POLICY_IMPL_CLASS_NAME + " could not be loaded", ex);  
        } catch (InstantiationException ex) {  
            throw new RuntimeException(  
                    POLICY_IMPL_CLASS_NAME + " could not be instantiated", ex);  
        } catch (IllegalAccessException ex) {  
            throw new RuntimeException(  
                    POLICY_IMPL_CLASS_NAME + " could not be instantiated", ex);  
        }  
    }  
  
    // 构造函数私有,保证是单例类   
    private PolicyManager() {}  
  
    // The static methods to spawn new policy-specific objects   
    public static Window makeNewWindow(Context context) {  
        //看看Policy的方法如何产生一个Window的。
        return sPolicy.makeNewWindow(context);  
    }  
  
    public static LayoutInflater makeNewLayoutInflater(Context context) {  
        return sPolicy.makeNewLayoutInflater(context);  
    }  
  
    public static WindowManagerPolicy makeNewWindowManager() {  
        return sPolicy.makeNewWindowManager();  
    }  
} 

查看Policy源码会发现,是new了一个PhoneWindow的实例。那么getWindow返回的就是一个PhoneWindow了。里面肯定也有三个setContentView方法了。

    
public void setContentView(int layoutResID){
        //mContentParent其实就是我们的xml布局显示的ViewGroup,是一个FlameLayout。
        //第一次,为null,就会执行,以后,会首先移除子View。
        if(mContentParent == null){
            installDecor();
        } else{
            mContentParent.removeAllViews();
            //这个方法什么事情也没用做。
            updateInflateParams();
        }
        //加载xml布局到mContentParent中,所以,我们可以猜想installDecor();肯定是可以得到一个mContentParent的。
        mViewInflate.inflate(layoutResID, mContentParent, mInflateParams);
        
        在Activity的attach方法中,还记得我们执行了一句mWindow.setCallback(this);由此看见,这个cb就是这个Activity自己。当Activity发生变化,就会执行onContentChanged方法。
        android.view.Window.Callback cb = getCallback();
        if(cb != null)
            cb.onContentChanged();
    }

查看installDecor方法

      
private void installDecor() {
        if (mDecor == null) {
            /*创建一个DecorView,
                private final class DecorView extends FrameLayout
            */
            mDecor = generateDecor();
            mDecor.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
            mDecor.setIsRootNamespace(true);
            if (!mInvalidatePanelMenuPosted && mInvalidatePanelMenuFeatures != 0) {
                mDecor.postOnAnimation(mInvalidatePanelMenuRunnable);
            }
        }
        if (mContentParent == null) {
            //根据窗口的风格修饰,选择对应的修饰布局文件,并且将id为content的FrameLayout赋值给mContentParent
            mContentParent = generateLayout(mDecor);
            //......
            //初始化一堆属性值
        }
    }
    
看一下如果mContentParent为null的时候,如何进行的。

protected ViewGroup generateLayout(DecorView decor){
        ......
        根据flag,style等属性获取到layoutResource,其实就是一个xml布局。这个布局分两块,
        LinearLayout
            FlameLayout(title)
            FlameLayout(content)这个其实就是我们的xml布局填充的父View。
        ......


        View in = mViewInflate.inflate(layoutResource, null, mInflateParams);
        decor.addView(in, new android.view.ViewGroup.LayoutParams(-1, -1));
        ViewGroup contentParent = (ViewGroup)findViewById(0x1050000);
        if(contentParent == null)
            throw new RuntimeException("Window couldn't find content container view");
    
        return contentParent;
    }
    
    根据上面的分析,可以知道setContentView都做了哪些事情。
    1:获得PhoneWindow对象。
    2:判断是否存在mContentParent,不存在的话就安装一个decorView,作为整个界面的根布局,里面有一个FlameLayout,其实就是mContentParent,而我们setContentView,把xml或者View作为mContentParent的子View来处理。
    
YOLO系列算法改进 | Neck改进篇 | 融合FAAFusion傅里叶角度对齐模块 | 攻克多尺度方向特征冲突,角度检测精度飙升! | CVPR 2026 YOLO系列算法改进 | Neck改进篇 | 融合FAAFusion傅里叶角度对齐模块 | 攻克多尺度方向特征冲突,角度检测精度飙升! | CVPR 2026 (以YOLO26最新目标检测模型为基础,利用FAAFusion傅里叶角度对齐模块改进Neck部分) 阅读详情

相关推荐

轻量级NAS的隐秘战场:比特米盒CumeBox2与CasaOS的生态融合实践

本文探讨了比特米盒CumeBox2轻量级NAS设备与CasaOS操作系统的生态融合实践。通过硬件选型、系统部署、性能优化和应用场景分析,展示了如何将CumeBox2与CasaOS深度整合,打造经济实用的家庭数据管理中心,特别适合入门级用户和小型办公环境。

rl6adventurer的博客 908

Android滑动冲突解决方法

现阶段你以为过不去的事,天大的事,当过去以后就会发现那只是屁大点事。实际上,也真的只是屁大点事儿。所有发生的都是应当发生的,无论是对是错。你需要为自己所做的任何决定和选择进行承担和负责。你需要做的是不断充实自己,做自己喜欢做的事情,让自己忙碌起来。你要感谢所有的人,所有人的到来,都是为了增加你感情的丰富程度,教会你如何处世如何为人,是他们让你波澜不惊的生活起了波澜,给你的生活增添了色彩,你会感激你

nicolelili1的专栏 1631

【图形学】Loop细分算法及半边结构实现(C++)

文章目录Loop 细分算法介绍增加新顶点更新旧顶点算法实现半边结构半边结构的表示方法半边结构的构造方法创建所有顶点创建所有面及半边半边结构的使用 Loop 细分 顾名思义,网格细分是将粗糙网格精细化的过程,如下动图。Loop细分是众多网格细分算法的一种,Loop细分仅仅对三角形网格模型有效。值得注意的是,虽然叫Loop细分,但是不能理解为“循环”细分,叫这个名字是因为作者的名字是这个而已。 下面是一个粗糙的兔子模型1000个面,进行3次细分 算法介绍 Loop细分算法主要分两步进行 增加新顶点:增加

wk_119的博客 8075

setContentView源码分析

转载请注明出处: 在Activity中,常常第一件事就是在onCreate里面调用setContentView来设置布局。大家都知道setContentView用来设置Activity的布局,但是有没有研究过setContentView究竟做了哪些事呢?本文就一起看看setContentView是如何加载我们的布局的。看完之后大家就会知道为什么使用requestWindowFeature设置窗口

fishle123的专栏 1398

dq轴坐标系下的电路方程

dq轴坐标系下的电路方程 dq轴坐标系是一种常见的电路方程,但是再dq轴坐标系下电路元件的电压电流dq轴存在一定的耦合,本文针对三相电路推导了dq轴坐标系下的电路电路方程进行一个推导,首先先列出来派克变换的公式 派克变换 [AdAqA0]=23[cos⁡(θ)cos⁡(θ−2π/3)cos⁡(θ+2π/3)−sin⁡(θ)−sin⁡(θ−2π/3)−sin⁡(θ+2π/3)1/21/21/2][AaAbAc]\left[\begin{array}{c}A_d\\A_q\\A_0 \end{array}\ri

Mr.Young的博客 1万+

MaaS 商业模式全面分析报告:从技术赋能到商业变现的全链条探索

MaaS(模型即服务)商业模式正成为AI产业主流,2024年上半年中国市场规模达2.5亿元,预计2027年占比将提升至47%。该模式通过云服务提供预训练AI模型,大幅降低企业应用AI的技术门槛和成本。核心盈利方式包括按使用量计费、订阅制、定制化服务等,其中混合模式因灵活性成为趋势。MaaS产业链包含模型提供商、云平台、应用开发商和最终用户,重塑了AI产业格局。随着《数据法案》等监管加强,数据增值服务面临更严格合规要求。未来五年,中国MaaS市场增速预计超50%,用户规模将从2025年2.1亿增至2030年5

芯片行业20年 · 参与定义实现千万级量产出货 · AI芯片PM 2926

【android java.lang.RuntimeException闪退,报错android.view.InflateException分析错误原因及解决方案】

添加图片控件后调试直接闪退,报错java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.recanapp/com.example.recanapp.MainActivity}: android.view.InflateException:最后是因为图片格式不对

安卓开发工程师 1385

SOME/IP协议详解「1.1·面向服务与面向信号」

面向信号和面向服务的区别,和举例子

雪云飞星的博客 5666

文件管理搜不到Android 里的文件,Android:在原始文件夹中添加文件后窗口找不到内容容器视图...

正在获取窗口找不到内容容器视图。这个错误询问应用程序何时将检查权限Android:在原始文件夹中添加文件后窗口找不到内容容器视图我注意到,对于穿着应用程序,我正在将穿着apk复制到原始文件夹中。它有大约2.5 Mb。添加这个我得到这次崩溃java.lang.RuntimeException: Window couldn't find content container viewat com.and...

weixin_39930276的博客 948

2025.05.30【转录组】|Ribo-seq数据流程详解(一 质量控制)

本文详细介绍了Ribo-seq数据的质控分析流程,重点讲解了使用fastp进行原始数据质控的关键步骤和参数设置。作者通过Snakemake自动化流程示例,展示了如何去除接头序列、过滤低质量reads、生成质控报告等操作。文章强调高质量的Ribo-seq数据对转录后调控和翻译动态研究的重要性,并提供了兼顾数据质量和下游分析需求的参数配置建议。该流程有助于研究人员规范高效地完成Ribo-seq数据质控,为后续分析提供可靠数据基础。

790

动量因子在A股市场的有效性分析:量化实证研究

验证动量因子在A股市场的有效性及时间周期性分析不同时间窗口(短期/中期/长期)对动量效应的影响量化交易成本、市场流动性对动量策略收益的侵蚀程度比较A股与成熟市场(如美股)动量效应的差异特征理论框架:行为金融学解释动量效应的产生机制技术实现:Python全流程代码实现动量因子计算与回测实证分析:统计检验、风险收益指标、敏感性分析应用拓展:结合市场微观结构的策略优化方案动量因子(Momentum Factor)

2501_92132293的博客 2512

从源码探索Activity布局加载过程

众所周知,Activity是承载布局的重要组件,是通过setContentView()方法来设置xml布局文件的,那么我们来提出几个问题 1.布局文件到底是怎么加载到Activity并显示到屏幕的呢? 2.我们给activity设置了主题,它对应的样式代码是在哪设置的呢? 下面我们跟踪源码来探索一下。 首先,我们点开setContentView()方法 publi...

qq_27246079的博客 408

用 ABAP LSMW 的 Standard Batch / Direct Input 稳准快迁移物料主数据:从 MM01 录制到 RMDATIND 直入的落地指南

本文详细介绍了SAP数据迁移中LSMW工具的使用方法,重点分析了物料主数据迁移的两种主要路径:Batch Input Recording和Standard Batch/Direct Input。前者通过录制事务操作实现快速起步,后者通过调用预置接口程序实现稳定高效的批量处理。文章深入解析了Standard Direct Input的具体实施步骤,包括对象属性设置、源结构定义、字段映射规则等关键环节,并特别强调了迁移前的准备工作(如编号策略、视图策略等)对项目成功的重要性。通过对比两种方法的优缺点,为不同业务

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 163

Android 深入了解 Window 、Activity、 View 三者关系

Window、Activity、View都经常用到,但三者关系还是没有系统的理清,今天咱们就开始整理整理这三者的关系: Window:顶级窗口外观和行为策略的抽象基类。唯一实现是 PhoneWindow类。 Activity:四大组件之一,它提供一个界面让用户点击和各种滑动操作。 View:代表用户界面组件的基本构建块,UI 组件。 源码:Android SDK 30 Activity.setContentView ...

帅次的博客 5005

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

Activity Window View 三者之间的关系

问题引入 代码写久了发现有些问题,到底那些view时怎么显示在屏幕上的,怎么显示在window上的,还有我们刚开始学习android时候,每次新建一个Activity,在onCreate方法中都会使用setContentView这个方法传递一个布局,它又是怎么显示到屏幕上的呢? 首先Actiivity就是创建了一个Window,Activity实际就是Context的一个子类,Contex...

程序员成长指北 1162

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Window 、Activity、 View 三者关系

ps:文中源码为API 28 经常听到和用到Window,Window到底是什么? 简单概括三者关系 View其实是Android中视图的呈现方式,它必须附着在Window这个抽象的概念上,因此有视图的地方就有Window。有视图的地方不仅仅有Activity,还有Dialog、Toast,除此之外还有一些依托Window实现的视图:PopupWindow、菜单,它们也是视图,有视图的地方就有Window。因此Activity、Dialog、Toast都对应着一个Window。 三者各自创建时机 这里是.

潇风寒月 590

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Activity、Window、View三者关系

目录介绍 01.Window,View,子Window 02.什么是Activity 03.什么是Window 04.什么是DecorView 05.什么是View 06.关系结构图 07.Window创建过程 08.创建机制分析 8.1 Activity实例的创建 8.2 Activity中Window的创建 8.3 DecorView的创建 弹窗系列博客 01.Activity、W...

weixin_33882452的博客 253

Android的Activity Window和View三者之间的关系解析

我们知道,Activity是安卓的四大组件之一,负责手机界面的展示和交互。那么他与Window和View是什么关系呢。 下面,我们看一个简单的界面:它的布局文件如下,很简单:<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

帅风的专栏 2418

Activity Window View 三者的关系

Activity Window View 三者的关系 1、在Activity中调用attach,创建了一个Window 2、创建的window是其子类PhoneWindow,在attach中创建PhoneWindow 3、在Activity中调用setContentView(R.layout.xxx) 4、其中实际上是调用的getWindow().setContentView() 5、调用PhoneWindow中的setContentView方法 6、...

zjxwon的博客 268

文化袁探索专栏——Activity、Window和View三者间关系

文化袁探索专栏——Activity、Window和View三者间关系 文化袁探索专栏——View三大流程#Measure 文化袁探索专栏——View三大流程#Layout 文化袁探索专栏——Handler消息分发机制 文化袁探索专栏——事件分发机制 文化袁探索专栏——Launcher进程启动流程 文化袁探索专栏——Activity启动流程 文化袁探索专栏——APP进程启动流程 文化袁探索专栏——自定义View实现细节 文化袁探索专栏——线程安全 文化袁探索专栏—— ...............

文化园 2139

深入解析Activity、Window、View三者之间的关系

本文摘要:Android UI框架的核心层级关系是Activity管理Window(通常为PhoneWindow),Window承载DecorView作为根视图,开发者通过setContentView()设置的View树则被添加到DecorView内部的mContentParent容器中。Activity负责生命周期管理,Window作为中间层处理UI请求,DecorView则整合系统UI和应用内容。源码分析显示,这一关系始于Activity创建时实例化PhoneWindow,并通过attach()方法建立

csdn_silent的博客 1352

解析Activity、Window、View三者关系

前言 从问题出发,往往能更明确的找到所求。本文将带着一个个的问题,结合源码,逐步解析Activity、Window、View的三者关系。 什么地方需要window? 一句话总结:有视图的地方就需要window Activity、Dialog、Toast... PopupWindow和Dialog有什么区别? 两者最根本的区别在于有没有新建一个window,PopupWindow没有新建,...

厚德出品,必是精品 2060

Android 深入了解 Window 、Activity、 View 三者关系,【金九银十

不知道从哪入手,咱们就从setContentView开始,比较刚创建的Android项目Activity和setContentView是必不可少的。记住看Activity的setContentView而不是AppCompatActivity的 来瞅瞅setContentView: public void setContentView(@LayoutRes int layoutResID) { //重点来了 getWindow().setContentView

m0_66155412的博客 592
上一篇: 通过style实现Activity的界面切换
下一篇: Webview获取连续H5页面的标题
arplay
博客等级 码龄12年 0粉丝 14原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址