插件式换肤框架搭建 - setContentView源码阅读

Android代码-安卓内涵段子app neihan 安卓内涵段子app 立即下载

1. 概述


  内涵段子架构第一阶段已经更新完了,后面我们主要是以google源码为主,今天我带大家来看一下setContentView的源码,请先看一下如果继承自Activity去打印一个TextView与继承自AppCompatActivity去打印一个TextView分别是这样的:

继承自Activity:  
android.widget.TextView{ac5cd17 V.ED..... ......ID 0,0-0,0 #7f0b002c app:id/text_view}

继承自AppCompatActivity:  
android.support.v7.widget.AppCompatTextView{392562b V.ED..... ......ID 0,0-0,0 #7f0b0055 app:id/text_view}

   谁能告诉我这到底是怎么啦?我布局里面明明是TextView为什么继承自AppCompatActivity就变成了AppCompatTextView,那么接下来我们就来看一下源码到底是怎么把我的TextView给拐走的。

所有分享大纲:2017Android进阶之路与你同行

视频讲解地址:http://pan.baidu.com/s/1pLNiBWZ

2. Activity的setContentView源码阅读


2.1 很多人都问过我怎么看源码,我只想说怎么看?当然是坐着点进去看啊!

    public void setContentView(@LayoutRes int layoutResID) {
        // 获取Window 调用window的setContentView方法,发现是抽象类,所以需要找具体的实现类PhoneWindow
        getWindow().setContentView(layoutResID);
    }

    // PhoneWindow 中的 setContentView方法
    @Override
    public void setContentView(int layoutResID) {
        // 如果mContentParent 等于空,调用installDecor();
        if (mContentParent == null) {
            installDecor();
        } else if (!hasFeature(FEATURE_CONTENT_TRANSITIONS)) {
            mContentParent.removeAllViews();
        }

        // 把我们自己的布局layoutId加入到mContentParent,我们set进来的布局原来是放在这里面的Soga
        mLayoutInflater.inflate(layoutResID, mContentParent);
    }

2.2 installDecor(),这个之前已经带大家看过一遍了,不过没办法再进来看看吧:  

    // This is the top-level view of the window, containing the window decor.
    // 看到这解释木有?
    private DecorView mDecor;

    private void installDecor() {    
        if (mDecor == null) {
           // 先去创建一个  DecorView 
           mDecor = generateDecor(-1);
        }
        // ......
        // 省略调一些代码,看着晕,不过这也太省了。
        if (mContentParent == null) {
           mContentParent = generateLayout(mDecor);
        }
    }

    // generateDecor 方法
    protected DecorView generateDecor(int featureId) {
        // 就是new一个DecorView ,DecorView extends FrameLayout 不同版本的源码有稍微的区别,
        // 低版本DecorView 是PhoneWindow的内部类,高版本是一个单独的类,不过这不影响。
        return new DecorView(context, featureId, this, getAttributes());
    }

    protected ViewGroup generateLayout(DecorView decor) {
        // Inflate the window decor.
        // 我看你到底怎么啦
        int layoutResource;
        // 都是一些判断,发现 layoutResource = 系统的一个资源文件,
        if(){}else if(){}else if(){
            // Embedded, so no decoration is needed.
            layoutResource = R.layout.screen_simple;
            // System.out.println("Simple!");
        }

        mDecor.startChanging();
        // 把布局解析加载到  DecorView 而加载的布局是一个系统提供的布局,不同版本不一样
        // 某些源码是 addView() 其实是一样的
        mDecor.onResourcesLoaded(mLayoutInflater, layoutResource);

        //  ID_ANDROID_CONTENT 是 android.R.id.content,这个View是从DecorView里面去找的,
        //  也就是    从系统的layoutResource里面找一个id是android.R.id.content的一个FrameLayout
        ViewGroup contentParent = (ViewGroup)findViewById(ID_ANDROID_CONTENT);

        // 返回
        return contentParent;
    }

  其实看源码一定要带着最初的出发点来看,要不然里面太多了根本找不到方向,如果带着思想来看那么就算跑偏了也可以从新再回来,我目前就是想弄清楚我们的 setContentView() 系统到底把我们的布局加到哪里去了。我先用文字总结一下,然后去画一张图:

  • Activity里面设置setContentView(),我们的布局显示主要是通过PhoneWindow,PhoneWindow获取实例化一个DecorView。
  • 实例化DecorView,然后做一系列的判断然后去解析系统的资源layoutId文件,至于解析哪一个资源文件会做判断比如有没有头部等等,把它解析加载到DecorView,资源layout里面有一个View的id是android.R.id.content。
  • 我们自己通过setContentView设置的布局id其实是解析到mParentContent里面的,也就是那个id叫做android.R.id.content的FarmeLayout,好了就这么多了。

3. AppCompatActivity的setContentView

    @Override
    public void setContentView(@LayoutRes int layoutResID) {
        // 跟我在网上看的完全不一样
        getDelegate().setContentView(layoutResID);
    }


    public AppCompatDelegate getDelegate() {
        if (mDelegate == null) {
            mDelegate = AppCompatDelegate.create(this, this);
        }
        return mDelegate;
    }

    // window 还是那个window ,留意一下就行 , 不同的版本返回 AppCompatDelegateImpl,但是都是相互继承
    // 最终继承都是继承  AppCompatDelegateImplV9 有的版本V7有的V9 好麻烦 嗨!
    private static AppCompatDelegate create(Context context, Window window,
            AppCompatCallback callback) {
        final int sdk = Build.VERSION.SDK_INT;
        if (BuildCompat.isAtLeastN()) {
            return new AppCompatDelegateImplN(context, window, callback);
        } else if (sdk >= 23) {
            return new AppCompatDelegateImplV23(context, window, callback);
        } else if (sdk >= 14) {
            return new AppCompatDelegateImplV14(context, window, callback);
        } else if (sdk >= 11) {
            return new AppCompatDelegateImplV11(context, window, callback);
        } else {
            return new AppCompatDelegateImplV9(context, window, callback);
        }
    }

    // 下面其实就没啥好看的了,一个一个点进去,仔细看看就好了。与Activity没啥区别了
    @Override
    public void setContentView(int resId) {
        ensureSubDecor();
        ViewGroup contentParent = (ViewGroup) mSubDecor.findViewById(android.R.id.content);
        contentParent.removeAllViews();
        LayoutInflater.from(mContext).inflate(resId, contentParent);
        mOriginalWindowCallback.onContentChanged();
    }

    private void ensureSubDecor() {
        mSubDecor = createSubDecor();
    }

4. AppCompatViewInflater源码分析


  看到这里还是不知道为什么我的TextView变成了AppCompatTextView,找啊找啊就找了这么个方法:

    @Override
    public void installViewFactory() {
        LayoutInflater layoutInflater = LayoutInflater.from(mContext);
        if (layoutInflater.getFactory() == null) {
            // 把LayoutInflater 的 Factory设置为了this,也就说待会创建View就会走自己的onCreateView方法
            // 如果看不懂还需要看一下 LayoutInflater 的源码,我们的LayoutInflater.from(mContext)其实是一个单例
            // 如果设置了Factory那么每次创建View都会先执行Factory的onCreateView方法
            LayoutInflaterCompat.setFactory(layoutInflater, this);
        } else {
            if (!(LayoutInflaterCompat.getFactory(layoutInflater)
                    instanceof AppCompatDelegateImplV7)) {
                Log.i(TAG, "The Activity's LayoutInflater already has a Factory installed"
                        + " so we can not install AppCompat's");
            }
        }
    }

    @Override
    public View createView(View parent, final String name, @NonNull Context context,
            @NonNull AttributeSet attrs) {
        // 看一下是不是 5.0 ,5.0 都自带什么效果我就不说了
        final boolean isPre21 = Build.VERSION.SDK_INT < 21;

        if (mAppCompatViewInflater == null) {
            mAppCompatViewInflater = new AppCompatViewInflater();
        }

        // We only want the View to inherit its context if we're running pre-v21
        final boolean inheritContext = isPre21 && shouldInheritContext((ViewParent) parent);
        // 通过 AppCompatViewInflater 去创建View
        return mAppCompatViewInflater.createView(parent, name, context, attrs, inheritContext,
                isPre21, /* Only read android:theme pre-L (L+ handles this anyway) */
                true, /* Read read app:theme as a fallback at all times for legacy reasons */
                VectorEnabledTintResources.shouldBeUsed() /* Only tint wrap the context if enabled */
        );
    }

  其实在讲数据库优化我们已经看过一次AppCompatViewInflater的源码了,创建View都是用的反射,只不过做了缓存和优化而已,我们写代码其实可以仿照源码来,给我们很好的思路。

public final View createView(View parent, final String name, @NonNull Context context,
            @NonNull AttributeSet attrs, boolean inheritContext,
            boolean readAndroidTheme, boolean readAppTheme, boolean wrapContext) {

        View view = null;
        // 果真找到你了,哈哈 ,做了替换
        // We need to 'inject' our tint aware Views in place of the standard framework versions
        switch (name) {
            case "TextView":
                view = new AppCompatTextView(context, attrs);
                break;
            case "ImageView":
                view = new AppCompatImageView(context, attrs);
                break;
            case "Button":
                view = new AppCompatButton(context, attrs);
                break;
            case "EditText":
                view = new AppCompatEditText(context, attrs);
                break;
            // .........
        }

        if (view == null && originalContext != context) {
            // If the original context does not equal our themed context, then we need to manually
            // inflate it using the name so that android:theme takes effect.
            view = createViewFromTag(context, name, attrs);
        }
        return view;
    }

private View createView(Context context, String name, String prefix)
            throws ClassNotFoundException, InflateException {
        // 先从构造缓存里面获取
        Constructor<? extends View> constructor = sConstructorMap.get(name);
        try {
            if (constructor == null) {
                // Class not found in the cache, see if it's real, and try to add it
                Class<? extends View> clazz = context.getClassLoader().loadClass(
                        prefix != null ? (prefix + name) : name).asSubclass(View.class);
                // 利用反射创建一个构造函数
                constructor = clazz.getConstructor(sConstructorSignature);
                sConstructorMap.put(name, constructor);
            }
            constructor.setAccessible(true);
            // 利用反射创建View的实例
            return constructor.newInstance(mConstructorArgs);
        } catch (Exception e) {
            // We do not want to catch these, lets return null and let the actual LayoutInflater
            // try
            return null;
        }
}

5. LayoutInflater源码分析


  LayoutInflater的源码我们分三个步骤去看相对来说会更加的系统:
  4. 1 如何获取LayoutInflater?
  4. 2 如何使用LayoutInflater?
  4. 3 布局的View是如何被实例化的?

  先来看看我们平时都是怎么去获取LayoutInflater的,这个我们其实并不陌生LayoutInflater.from(context):

    /**
    * Obtains the LayoutInflater from the given context.
    */
    // 是一个静态的方法
    public static LayoutInflater from(Context context) {
        // 通过context获取系统的服务
        LayoutInflater LayoutInflater =
                // context.getSystemService()是一个抽象类,所以我们必须找到实现类ContextImpl
                (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        if (LayoutInflater == null) {
            throw new AssertionError("LayoutInflater not found.");
        }
        return LayoutInflater;
    }


    // ContextImpl 里面的实现方法
    @Override
    public Object getSystemService(String name) {
        return SystemServiceRegistry.getSystemService(this, name);
    }

    /**
     * Gets a system service from a given context.
     */
    // SystemServiceRegistry 里面的getSystemService方法
    public static Object getSystemService(ContextImpl ctx, String name) {
        ServiceFetcher<?> fetcher = SYSTEM_SERVICE_FETCHERS.get(name);
        return fetcher != null ? fetcher.getService(ctx) : null;
    }

    // 这是一个静态的HashMap集合
    private static final HashMap<String, ServiceFetcher<?>> SYSTEM_SERVICE_FETCHERS =
            new HashMap<String, ServiceFetcher<?>>();

    // 静态的代码块中
    static{
         // 注册LayoutInflater服务
         registerService(Context.LAYOUT_INFLATER_SERVICE, LayoutInflater.class,
                new CachedServiceFetcher<LayoutInflater>() {
            @Override
            public LayoutInflater createService(ContextImpl ctx) {
                return new PhoneLayoutInflater(ctx.getOuterContext());
            }});
         }
         // 注册很多的其他服务......
    }

  接下来大致的整理一下获取LayoutInflater的思路,通过Context的实现类ContextImpl获取的,最终是通过SystemServiceRegistry.getSystemService()方法,而SYSTEM_SERVICE_FETCHERS是一个静态的HashMap,初始化是在静态代码块中通过registerService注册了很多服务。所以到目前为止我们有两个思想对于我们后面插件化的皮肤框架有很大的关系,第一LayoutInflater其实是一个系统的服务,第二每次通过LayoutInflater.form(context)是一个静态的单例类无论在哪里获取都是同一个对象。接下来我们来看一下加载布局的三种方式:

1.View.inflate(context,layoutId,parent);
2.LayoutInflater.from(context).inflate(layoutId,parent);
3.LayoutInflater.from(context).inflate(layoutId,parent,attachToRoot);

1.View.inflate(context,layoutId,parent);

    // 其实就是调用的  LayoutInflater.from(context).inflate(layoutId,parent);
    public static View inflate(Context context, @LayoutRes int resource, ViewGroup root) {
        LayoutInflater factory = LayoutInflater.from(context);
        return factory.inflate(resource, root);
    }

2.LayoutInflater.from(context).inflate(layoutId,parent);

    // 其实就是调用的 LayoutInflater.from(context).inflate(layoutId,parent,attachToRoot);
    public View inflate(@LayoutRes int resource, @Nullable ViewGroup root) {
         return inflate(resource, root, root != null);
    }

3.LayoutInflater.from(context).inflate(layoutId,parent,attachToRoot); 其实最终都是调用的该方法,我们关键是要弄清楚这个参数的概念,尤其是attachToRoot:

    public View inflate(@LayoutRes int resource, @Nullable ViewGroup root, boolean attachToRoot) {
        final Resources res = getContext().getResources();
        if (DEBUG) {
            Log.d(TAG, "INFLATING from resource: \"" + res.getResourceName(resource) + "\" ("
                    + Integer.toHexString(resource) + ")");
        }
        // 获取一个 XmlResourceParser 解析器,这个应该并不陌生,就是待会需要去解析我们的layoutId.xml文件
        // 这个到后面的插件化架构再去详细讲解
        final XmlResourceParser parser = res.getLayout(resource);
        try {
            return inflate(parser, root, attachToRoot);
        } finally {
            parser.close();
        }
    }

    public View inflate(XmlPullParser parser, @Nullable ViewGroup root, boolean attachToRoot) {
    synchronized (mConstructorArgs) {
        ......
        //保存传进来的这个view
        View result = root;

        try {
            // Look for the root node.
            int type;
            //在这里找到root标签
            while ((type = parser.next()) != XmlPullParser.START_TAG &&
                    type != XmlPullParser.END_DOCUMENT) {
                // Empty
            }

            if (type != XmlPullParser.START_TAG) {
                throw new InflateException(parser.getPositionDescription()
                        + ": No start tag found!");
            }
            //获取这个root标签的名字
            final String name = parser.getName();
             ......

            //判断是否merge标签
            if (TAG_MERGE.equals(name)) {
                if (root == null || !attachToRoot) {
                    throw new InflateException("<merge /> can be used only with a valid "
                            + "ViewGroup root and attachToRoot=true");
                }
                //这里直接加载页面,忽略merge标签,直接传root进rInflate进行加载子view
                rInflate(parser, root, inflaterContext, attrs, false);
            } else {
                //通过标签来获取view
                //先获取加载资源文件中的根view
                final View temp = createViewFromTag(root, name, inflaterContext, attrs);

                //布局参数          
                ViewGroup.LayoutParams params = null;

                //关键代码A
                if (root != null) {
                    params = root.generateLayoutParams(attrs);
                    if (!attachToRoot) {
                        //temp设置布局参数
                        temp.setLayoutParams(params);
                    }
                }
                  ......
                //关键代码B
                //在这里,先获取到了temp,再把temp当做root传进去rInflateChildren
                //进行加载temp后面的子view
                rInflateChildren(parser, temp, attrs, true);
                  ......

                 //关键代码C
                if (root != null && attachToRoot) {
                    //把view添加到root中并设置布局参数
                    root.addView(temp, params);
                }

                //关键代码D
                if (root == null || !attachToRoot) {
                    result = temp;
                }
            }

        } catch (XmlPullParserException e) {
            ......
        } catch (Exception e) {
            ......
        } finally {
            ......
        }

        return result;
       }
    }
    // 创建View
    View createViewFromTag(View parent, String name, Context context, AttributeSet attrs,
            boolean ignoreThemeAttr) {
        // ......
        try {
            // 创建我们的View
            View view;
            if (mFactory2 != null) {
                // 先通过mFactory2 创建,其实在 AppCompatActivity里面会走这个方法,也就会去替换某些控件
                // 所以我们就 看到了上面的内容
                view = mFactory2.onCreateView(parent, name, context, attrs);
            } else if (mFactory != null) {
                // 走mFactory 
                view = mFactory.onCreateView(name, context, attrs);
            } else {
                view = null;
            }
            // ......省略
            if (view == null) {
                final Object lastContext = mConstructorArgs[0];
                mConstructorArgs[0] = context;
                try {
                    // 判断是不是自定义View,自定义View在布局文件中com.hc.BannerView是个全类名,
                    // 而系统的View在布局文件中不是全类名 TextView
                    if (-1 == name.indexOf('.')) {
                        view = onCreateView(parent, name, attrs);
                    } else {
                        view = createView(name, null, attrs);
                    }
                } finally {
                    mConstructorArgs[0] = lastContext;
                }
            }

            return view;
        } catch (InflateException e) {
            // ........
        }
    }
    // 创建View
    public final View createView(String name, String prefix, AttributeSet attrs)
            throws ClassNotFoundException, InflateException {
        // 做一些反射的性能优化

        try {
            // 先从缓存中拿,这是没拿到的情况
            if (constructor == null) {
                // Class not found in the cache, see if it's real, and try to add it
                // 加载 clazz
                clazz = mContext.getClassLoader().loadClass(
                        prefix != null ? (prefix + name) : name).asSubclass(View.class);

                // 创建View的构造函数
                constructor = clazz.getConstructor(mConstructorSignature);
                constructor.setAccessible(true);
                // 加入缓存集合集合
                sConstructorMap.put(name, constructor);
            } else {

            }
            // 通过反射创建View
            final View view = constructor.newInstance(args);
            return view;

        } catch (NoSuchMethodException e) {
            // ......省略部分代码
        }
    }

  这里有两个思想比较重要第一个View的创建是通过当前View的全类名反射实例化的View,第二个View的创建首先会走mFactory2,然后会走mFactory,只要不为空先会去执行Factory的onCreateView方法,最后才会走系统的LayoutInflater里面的createView()方法,所以我们完全可以自己去实例化View,这对于我们的插件化换肤很有帮助。
  基于插件式换肤框架搭建 - 资源加载源码分析和插件式换肤框架搭建 - setContentView源码阅读这两篇文章我们完全可以自己动手搭建一套换肤框架了,我们下期再见。  

  所有分享大纲:2017Android进阶之路与你同行

  视频讲解地址:http://pan.baidu.com/s/1pLNiBWZ

内涵段子APP界面UI 用hbuider5做的仿内涵段子APP前端,用户登陆注册,首页,轮播图,导航栏(底部,头部),子界面切换,登陆判断等 立即下载

相关推荐

用RN写的类似于快手、内涵段子等的一个段子APP

用RN写的一个段子APP,模仿内涵快手火山之类的app模式,有视频列表,视频详情,图片列表,图片详情,点击视频列表中的视频可以播放视频,暂停重新播放等。图片列表页看图片信息,都是段子类的图片视频。数据请求的接口不断更新,压缩包中有打包好的包可以直接安装在安卓手机上(视频不断更新、随机取等。)。

Android插件式换肤框架搭建 - setContentView源码阅读

1. 概述  内涵段子架构第一阶段已经更新完了,后面我们主要是以google源码为主,今天我带大家来看一下setContentView的源码,请先看一下如果继承自Activity去打印一个TextView与继承自AppCompatActivity去打印一个TextView分别是这样的:继承自Activity: android.widget.TextView{ac5cd17 V.ED..... .

z240336124的专栏 840

Qt 5.9.1 32位下,手把手搞定周立功CAN二次开发库的加载与配置(含常见错误排查)

本文详细介绍了在Qt 5.9.1 32位环境下配置周立功CAN二次开发库的完整流程,包括环境准备、项目配置、常见错误排查及性能优化建议。特别针对MinGW 32bit环境,提供了.pro文件的精准配置和DLL部署策略,帮助开发者快速解决库文件匹配、编译报错和运行时问题,实现高效的CAN总线通信开发。

weixin_28717431的博客 359

内涵段子网站源码

★模板安装方法★ 1、安装dede系统。(如果您已经安装,请跳过本步.)直接运行:http://您的域名/install 2、将web文件夹内的所有文件和文件夹上传并覆盖到织梦的安装目录 3、确定网站风格(无论是否修改,都点击一下确定): (2)将‘站点根网址’改为您的网址,(本地安装请保持。) (3)点击‘确定’按钮 (4)更新整站缓存:点击‘生成’-’更新系统缓存’ (5)更新网站:点击‘生成’-‘一键更新网站 ’-更新所有-开始更新点击‘生成’-’更新主页html’,→将defa...

极乐数据 1616

博途 V16(TIA portal V16)安装教程

本文提供了西门子TIA Portal V16软件的完整安装指南。内容包括百度网盘下载链接(提取码kv69)、详细安装步骤(关闭安全保护、典型安装设置)、授权破解方法,以及PLCSIM仿真功能的使用说明。重点演示了S7-1200 PLC程序的仿真过程,解析了仿真界面各元素功能,包括状态指示灯(RUN/STOP/ERROR)、操作按钮(RUN/STOP/MRES)和网络接口状态等。通过图文并茂的方式,完整呈现了从软件安装到PLC程序仿真的全流程操作。

lingchen1906的博客 7155

SAP PCC成本收集器实战:从配置到结算的完整流程解析

本文详细解析了SAP PCC成本收集器从配置到结算的完整流程,特别适用于重复制造行业。通过实战案例和配置要点,帮助用户掌握物料分类账管理、成本中心费用归集及差异分析等核心功能,提升企业生产成本控制效率。

weixin_29251567的博客 908

内涵社区APP,一款集内涵段子,百思不得其姐,煎蛋于一身的搞笑社区

效果图 先上效果图 项目介绍 内涵社区,一款集内涵段子,百思不得其姐,煎蛋于一身的搞笑社区。 项目虽小,五脏俱全,学习这个项目,你将学到 Android Studio开发Android的基本配置对MD风格的Theme兼容对Volley网络请求库的封装和自定义对Xutils网络请求库的封装和自定义Application、Activity和Fragment基类的基本设计MVC架构的使

林朝昆的博客 7629

南大计算机2024保研笔试:编译原理等5门专业课考点分布与408复习避坑指南

本文详细解析了南京大学计算机2024保研笔试的考点分布与复习策略,重点突出编译原理(占比28%-32%)和离散数学的特色考核。提供跨课程复习方法、真题题型分析及高效备考建议,帮助考生突破传统408框架,应对南大独特的命题风格。

weixin_29304985的博客 368

iOS高仿app源码:10天时间纯代码打造高仿优质《内涵段子》

Github 地址 https://github.com/Charlesyaoxin/NeiHanDuanZI 介绍: 花了不太到两周的闲余时间模仿了一下今日头条旗下的iOS端app内涵段子,如果喜欢的话请前往我的Github点个星。(8.30-9.11) 这个项目是用OC编写,如果有的朋友已经下载下来看了这个项目, 就会意识到这个项目没有一个storyboard或者是nib,不是因

努力,可能成功!放弃,注定失败! 2441

具身智能的建模和方法(具身智能入门一)

本文以机械臂将小红方块移动到目标位置为例对具身智能的建模和方法进行介绍,如下图所示,该例子来自https://ai-workshops.github.io/building-and-working-in-environments-for-embodied-ai-cvpr-2022/。

weixin_39699362的博客 1479

从硬件到软件:TSMaster报文过滤全链路配置指南(含同星设备适配)

本文详细介绍了TSMaster平台下CAN/LIN/FlexRay总线的报文过滤全链路配置指南,特别针对同星TC1016等硬件的兼容性进行实战演示。从硬件层预过滤到软件层可编程过滤,提供五维过滤体系构建方法,帮助工程师提升车载诊断与总线分析效率。重点解析混合总线过滤策略优化及诊断场景下的特殊过滤方案。

tensorflowjs6的博客 410

插件式换肤框架搭建 setContentView源码阅读

1. 概述   内涵段子架构第一阶段已经更新完了,后面我们主要是以google源码为主,今天我带大家来看一下setContentView的源码,请先看一下如果继承自Activity去打印一个TextView与继承自AppCompatActivity去打印一个TextView分别是这样的: 继承自Activity: android.widget.TextView{ac5cd17 V.ED......

weixin_33798152的博客 152

GEE初学:谷歌地球引擎GEE入门指南(最新注册全流程)

本教程详细介绍了谷歌地球引擎(GEE)的注册与基础操作流程。主要内容包括:1)非商业账号注册步骤,需提供学术机构凭证和研究目的;2)Google Cloud项目创建与API激活;3)Shapefile文件上传方法及资源ID获取;4)JavaScript脚本编写与地图可视化实现。教程通过代码示例展示了两种多边形显示方式(填充和轮廓模式),并强调了GEE的云端处理优势,包括免费访问40多年卫星数据、无需本地高性能硬件等特点。整个流程从账号注册到首个地图可视化完成约需10-15分钟,适合遥感分析初学者快速入门。

此星光明博客 2201

Android Framework 之换肤框架

通过学习研究,Android换肤原理和思路,我们可以深入了解学习Android 对于控件加载流程 Android动态换肤框架实现_派派的生活-CSDN博客 插件式换肤框架搭建 - setContentView源码阅读 - 简书https://www.jianshu.com/p/531d1168b3ee ...

C++ JAVA的专栏 709

mbedtls | 01 - 移植mbedtls库到STM32的两种方法

一、mbedtls 开源库 1. mbedtls是什么 Mbed TLS是一个开源、可移植、易于使用、代码可读性高的SSL库。可实现加密原语,X.509证书操作以及SSL / TLS和 DTLS 协议,它的代码占用空间小,非常适合用于嵌入式系统。 mbedtls遵循 Apache 2.0 开源许可协议,目前由 TrustedFirmware 维护(Linaro主持的一个治理开放社区项目),在Github上已收获 2.6k star,目前Github上发布的最新版本为 2.24.0 版本,开源仓库地址为:

Mculover666的博客(嵌入式) 1万+

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

源码阅读分析 - Window底层原理与系统架构

做了一段的时间的 android 我们就开始听到有人说 AMS、WMS、Window、WindowManager、WindowManagerService等等这些词汇,可能了解但是脑海里未必有架构图, 这次我们就从源码的角度来了解一下。在阅读本文之前希望你可以花点时间了解下面几篇文章:1. 插件式换肤框架搭建 - setContentView源码阅读 2. Android进程间的通信 - IPC(

z240336124的专栏 1494

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Android最全的setContentView源码分析

我们在开发过程中,在布局文件里添加TextView,代码运行起来就可以看到对应文字显示出来,那系统是如何把我们的TextView加载并显示出来的呢?通过对的源码分析,了解了View是如何添加到当前界面上的,对于插件换肤方案有很大的帮助!ღ( ´・ᴗ・` )

故不积跬步无以至千里 1320

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

setContentView详解

setContentView我们在Activity中经常见到,它的作用就是把我们的布局文件放在Activity中显示,下面我们根据源码分析setContentView是如何做到的。

Allence的博客 1万+

项目框架及源码分享(各种搞笑图文,内涵段子)

本应用为娱乐类应用,汇集了各种笑话集锦、内涵段子及搞笑图片。

u012151933的专栏 5168

MUI 搞笑段子手机app项目源码

自己研究了几天的MUI框架,尝试开发了个搞笑段子的app。目前功能尚不完善,主页可以看搞笑短视频,有个刷新按钮,项目包含了登录注册修改密码等页面,有想学习mui框架的朋友可以下载源码学习一下,项目中也有打包好的安装包,手机可以直接安装!下载地址:https://download.csdn.net/download/m0_37879490/10346656    ...

西木的博客 3255

setContentView源码分析

public class ActivityTest extends AppCompatActivity{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test); } } ↓ ...

本人很懒 1596

Android 微信,QQ,新浪三方登录及分享官方SDK集成

集成过程中踩了不少坑,我会尽量写的详细一点。 微信 关于开发平台申请appID,appSecret,下载SDK等步骤不表。 环境配置 libammsdk.jar导入lib,androidManifest中添加基本权限 name="android.permission.INTERNET"/> name="android.permission.ACCESS_NETWORK_STATE

ChatHello的博客 2110
上一篇: Java基础类---String类
下一篇: Android Bitmap知识梳理学习
ChatHello
博客等级 码龄11年 43粉丝 58原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址