当前位置: 首页 > news >正文

自己做网站要服务器吗益阳网站seo

自己做网站要服务器吗,益阳网站seo,免费找客户的软件,网站你应该知道我说的是什么吧原文#xff1a;http://mobile.51cto.com/hot-314700.htm 上一节我们研究了Launcher的整体结构#xff0c;这一节我们看看整个Laucher的入口点#xff0c;同时Laucher在加载了它的布局文件Laucher.xml时都干了些什么。 我们在源代码中可以找到LauncherApplication#xff0… 原文http://mobile.51cto.com/hot-314700.htm 上一节我们研究了Launcher的整体结构这一节我们看看整个Laucher的入口点同时Laucher在加载了它的布局文件Laucher.xml时都干了些什么。 我们在源代码中可以找到LauncherApplication 它继承了Application类当整个Launcher启动时它就是整个程序的入口。我们先来看它们在AndroidManifest.xml中是怎么配置的。 application     android:namecom.android.launcher2.LauncherApplication     android:labelstring/application_name     android:icondrawable/ic_launcher_home     android:hardwareAcceleratedbool/config_hardwareAccelerated     android:largeHeapbool/config_largeHeap      首先通过android:name指定了整个Launcher的Application也就是入口是在 com.android.launcher2.LauncherApplication这个路径下android:lable指定了桌面的名字是叫 Launcher,如果要改名字就改values文件夹的string.xml中的相应属性就可以了。android:icon指定了Laucher的图标这个图标可以在应用程序管理器中看见如下图所示是个可爱机器人住在一个小房子里面如果需要更改Laucher的图片重新设置这个属性就可以了。 android:hardwareAcceleratedbool/config_hardwareAccelerated 指定了整个应用程序是启用硬件加速的这样整个应用程序的运行速度会更快。 android:largeHeapbool/config_largeHeap 指定了应用程序使用了大的堆内存能在一定程度上避免对内存out of memory错误的出现。我们可以在values文件夹的config.xml中看到对是否启用硬件加速和大内存的配置。如下所示 bool nameconfig_hardwareAcceleratedtrue/bool bool nameconfig_largeHeapfalse/bool  在Application中onCreate()方法通过sIsScreenLarge screenSize Configuration.SCREENLAYOUT_SIZE_LARGE || screenSize Configuration.SCREENLAYOUT_SIZE_XLARGE; 和sScreenDensity getResources().getDisplayMetrics().density;来判断是否是大屏幕同时得到它的屏幕密度。同时通过mIconCache new IconCache(this); 来设置了应用程序的图标的cache然后申明了LauncherModelmModel new LauncherModel(this, mIconCache); LauncherModel主要用于加载桌面的图标、插件和文件夹同时LaucherModel是一个广播接收器在程序包发生改变、区域、或者配置文件发生改变时都会发送广播给LaucherModelLaucherModel会根据不同的广播来做相应加载操作此部分会在后面做详细介绍。 在LauncherApplication完成初始化工作之后我们就来到了Launcher.java的onCreate()方法同样是启动桌面时的一系列初始化工作。 首先需要注意的是在加载launcher布局文件时的一个TraceView的调试方法它能够对在他们之间的方法进行图形化的性能分析并且能够具体到method 代码如下 if (PROFILE_STARTUP) {       android.os.Debug.startMethodTracing(               Environment.getDataDirectory()  /data/com.android.launcher/launcher);   }   if (PROFILE_STARTUP) {       android.os.Debug.stopMethodTracing();   }   我指定的生成性能分析的路径是/data/data/com.android.launcher/launcher启动launcher后我们会发现在指定的目录下生成了launcher.trace文件如下图所示 把launcher.trace文件通过DDMS pull到电脑上在SDK的tools目录里执行traceview工具来打开launcher.trace .如下图所示 点击查看大图 可以看到setContentView使用了448.623ms占整个跟踪代码时间的62%所以说在加载布局文件时肯定经过了一系列的加载运算我们接着分析。 当加载launcher布局文件的过程时最为关键的时对整个workspace的加载workspace是一个自定义组件它的继承关系如下所示可以看到Workspace实际上也是一个ViewGroup可以加入其他控件。 当ViewGroup组件进行加载的时候首先会读取本控件对应的XML文件然后Framework层会执行它的onMeasure()方法根据它所包含的子控件大小来计算出整个控件要在屏幕上占的大小。Workspace重写了ViewGroup的onMeasure方法(在PagedView中)在workspace中是对5个子CellLayout进行测量的方法如下, 具体含义请看注释 Override     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {         if (!mIsDataReady) {             super.onMeasure(widthMeasureSpec, heightMeasureSpec);             return;         }         //得到宽度的模式在配置文件中对应的是match_parent 或者 wrap_content和其大小         final int widthMode  MeasureSpec.getMode(widthMeasureSpec);         final int widthSize  MeasureSpec.getSize(widthMeasureSpec);         //宽度必须是match_parent,否则会抛出异常。         if (widthMode ! MeasureSpec.EXACTLY) {             throw new IllegalStateException(Workspace can only be used in EXACTLY mode.);         }          /* Allow the height to be set as WRAP_CONTENT. This allows the particular case          * of the All apps view on XLarge displays to not take up more space then it needs. Width          * is still not allowed to be set as WRAP_CONTENT since many parts of the code expect          * each page to have the same width.          */         //高度允许是wrap_content,因为在大屏幕的情况下会占了多余的位置         final int heightMode  MeasureSpec.getMode(heightMeasureSpec);         int heightSize  MeasureSpec.getSize(heightMeasureSpec);         int maxChildHeight  0;         //得到在竖值方向上和水平方向上的Padding          final int verticalPadding  mPaddingTop  mPaddingBottom;         final int horizontalPadding  mPaddingLeft  mPaddingRight;           // The children are given the same width and height as the workspace         // unless they were set to WRAP_CONTENT         if (DEBUG) Log.d(TAG, PagedView.onMeasure():   widthSize  ,   heightSize    mPaddingTopmPaddingTop   mPaddingBottommPaddingBottom);         final int childCount  getChildCount();         //对workspace的子View进行遍历从而对它的几个子view进行测量。         for (int i  0; i  childCount; i) {             // disallowing padding in paged view (just pass 0)             final View child  getPageAt(i);             final LayoutParams lp  (LayoutParams) child.getLayoutParams();              int childWidthMode;             if (lp.width  LayoutParams.WRAP_CONTENT) {                 childWidthMode  MeasureSpec.AT_MOST;             } else {                 childWidthMode  MeasureSpec.EXACTLY;             }              int childHeightMode;             if (lp.height  LayoutParams.WRAP_CONTENT) {                 childHeightMode  MeasureSpec.AT_MOST;             } else {                 childHeightMode  MeasureSpec.EXACTLY;             }              final int childWidthMeasureSpec                  MeasureSpec.makeMeasureSpec(widthSize - horizontalPadding, childWidthMode);             final int childHeightMeasureSpec                  MeasureSpec.makeMeasureSpec(heightSize - verticalPadding, childHeightMode);             //对子View的大小进行设置传入width和height参数             child.measure(childWidthMeasureSpec, childHeightMeasureSpec);             maxChildHeight  Math.max(maxChildHeight, child.getMeasuredHeight());             if (DEBUG) Log.d(TAG, \tmeasure-child  i  :   child.getMeasuredWidth()  ,                       child.getMeasuredHeight());         }          if (heightMode  MeasureSpec.AT_MOST) {             heightSize  maxChildHeight  verticalPadding;         }         //存储测量后的宽度和高度         setMeasuredDimension(widthSize, heightSize);          // We cant call getChildOffset/getRelativeChildOffset until we set the measured dimensions.         // We also wait until we set the measured dimensions before flushing the cache as well, to         // ensure that the cache is filled with good values.         invalidateCachedOffsets();         updateScrollingIndicatorPosition();          if (childCount  0) {             mMaxScrollX  getChildOffset(childCount - 1) - getRelativeChildOffset(childCount - 1);         } else {             mMaxScrollX  0;         }     }  测量完毕之后就可以对子控件进行布局了,这时候Framework层会调用PagedView中重写的onLayout方法。 Override    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {        if (!mIsDataReady) {            return;        }         if (DEBUG) Log.d(TAG, PagedView.onLayout());        //竖值方向的Padding        final int verticalPadding  mPaddingTop  mPaddingBottom;        final int childCount  getChildCount();        int childLeft  0;        if (childCount  0) {            if (DEBUG) Log.d(TAG, getRelativeChildOffset():   getMeasuredWidth()  ,                      getChildWidth(0));            childLeft  getRelativeChildOffset(0);            //偏移量为0            if (DEBUG) Log.d(TAG, childLeft:childLeft);               // Calculate the variable page spacing if necessary            // 如果mPageSpacing小于0的话就重新计算mPageSpacing并且给它赋值。            if (mPageSpacing  0) {                setPageSpacing(((right - left) - getChildAt(0).getMeasuredWidth()) / 2);            }        }         for (int i  0; i  childCount; i) {            final View child  getPageAt(i);            if (child.getVisibility() ! View.GONE) {                final int childWidth  getScaledMeasuredWidth(child);                final int childchildHeight  child.getMeasuredHeight();                int childTop  mPaddingTop;                if (mCenterPagesVertically) {                    childTop  ((getMeasuredHeight() - verticalPadding) - childHeight) / 2;                }                                if (DEBUG) Log.d(TAG, \tlayout-child  i  :   childLeft  ,   childTop);                //把5个CellLayout布局到相应的位置layout的4个参数分别是 左、上、右、下。                child.layout(childLeft, childTop,                        childLeft  child.getMeasuredWidth(), childTop  childHeight);                childLeft  childWidth  mPageSpacing;            }        }        //第一次布局完毕之后就根据当前页偏移量当前页距离Workspace最左边的距离滚动到默认的页面去第一次布局时        //默认的当前页是3则它的便宜量就是两个CellLayout的宽度。        if (mFirstLayout  mCurrentPage  0  mCurrentPage  getChildCount()) {            setHorizontalScrollBarEnabled(false);            int newX  getChildOffset(mCurrentPage) - getRelativeChildOffset(mCurrentPage);            //滚动到指定的位置            scrollTo(newX, 0);            mScroller.setFinalX(newX);            if (DEBUG) Log.d(TAG, newX is newX);            setHorizontalScrollBarEnabled(true);            mFirstLayout  false;        }         if (mFirstLayout  mCurrentPage  0  mCurrentPage  getChildCount()) {            mFirstLayout  false;        }    } 转载于:https://www.cnblogs.com/deve/archive/2012/06/28/2568977.html
http://www.sadfv.cn/news/4440/

相关文章:

  • 引用网站的内容如何做注释软件技术毕业设计项目
  • 彩票网站建设维护武清做网站的
  • 福州鼓楼区网站建设投票网站建设
  • 企业网站功能模块设计网站开发工程师制作kpi
  • 建筑公司网站设计详情多语言做网站
  • 如何快速备案网站专业免费网站建设哪里便宜
  • 大庆市住房和城乡建设局网站网站流量查询 优帮云
  • react.js做的网站手机网站一键分享到微信
  • 营销网站排行榜前十名手机网站分享代码
  • 无锡市建设银行总行网站连云港企业做网站
  • 企业科技网站建设万维网站建设
  • 如何做网站推广赚钱工信部网站备案查询 手机
  • 做情人在那个网站大连旅顺港
  • 佛山有哪些公司佛山seo优化
  • 顺德电子商务网站建设网站 源码 下载
  • 做logo有哪些网站公司做网站哪里好
  • 企业网站建设要多久WordPress手机端有广告
  • 曲靖房地产网站开发域名备案查询网站备案
  • 大朗镇仿做网站网站如何做好优化
  • 大学生可做的网站主题WordPress安装jetpack
  • 网站被人做跳转mg线上注册
  • 做公众号的网站模板下载涿州做网站的公司
  • 企业网站设计分析济南官网seo技术厂家
  • 网站 类库jsp网站开发 开题依据
  • wordpress博客网站多少钱推盟
  • 自己做优惠券网站网站建设比较好的公司
  • 兰州网站建设lzwlxc重庆妇科医院在线咨询
  • 义乌网站建设微信开发wordpress手机导航栏设置
  • 图书信息管理系统代码网站建设论坛企业推广
  • 企业网站网页布局代写简历哪个平台比较好