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

可以做彩字的网站淘宝自己网站怎么建设

可以做彩字的网站,淘宝自己网站怎么建设,滨州网站建设电话,建个短视频网站在日常开发中我们常常使用LinearLayout作为布局Group#xff0c;本文从其源码实现出发分析测量流程。大家可以带着问题进入下面的分析流程#xff0c;看看是否能找到答案。 垂直测量 View的测量入口方法是onmeasure方法。LinearLayout的onMeasure方法根据其方向而做不同的处…在日常开发中我们常常使用LinearLayout作为布局Group本文从其源码实现出发分析测量流程。大家可以带着问题进入下面的分析流程看看是否能找到答案。 垂直测量 View的测量入口方法是onmeasure方法。LinearLayout的onMeasure方法根据其方向而做不同的处理。本文我们选择垂直布局测量看下。 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {if (mOrientation VERTICAL) {measureVertical(widthMeasureSpec, heightMeasureSpec);} else {measureHorizontal(widthMeasureSpec, heightMeasureSpec);}}而measureVertical方法整体上分为2个部分。即两次测量。 第一次测量 for (int i 0; i count; i) {final View child getVirtualChildAt(i);if (child null) {mTotalLength measureNullChild(i);continue;}if (child.getVisibility() View.GONE) {//GONE的View不用测量注意INVISIBLE还是会测量的i getChildrenSkipCount(child, i);continue;}nonSkippedChildCount;if (hasDividerBeforeChildAt(i)) {//mTotalLength为总的使用高度这里加上分割线的高度mTotalLength mDividerHeight;}final LayoutParams lp (LayoutParams) child.getLayoutParams();//totalWeight为总的weight这里主要是统计所有使用weight的view的总weight为后续测量weight0的View作准备totalWeight lp.weight;final boolean useExcessSpace lp.height 0 lp.weight 0;if (heightMode MeasureSpec.EXACTLY useExcessSpace) {// 优化不必费心测量仅使用多余空间布局的子视图。如果我们有空间可供分配这些视图将在稍后进行测量。//这里是指当LinearLayout为精确模式子View使用了weight。那么本次就不用测量该View而只是将其margin统计到已使用的高度上final int totalLength mTotalLength;mTotalLength Math.max(totalLength, totalLength lp.topMargin lp.bottomMargin);skippedMeasure true;} else {if (useExcessSpace) {// heightMode 为 UNSPECIFIED 或 AT_MOST并且此子项仅使用多余的空间进行布局。使用 WRAP_CONTENT 进行测量以便我们能够找出视图的最佳高度。测量后我们将恢复原始高度 0lp.height LayoutParams.WRAP_CONTENT;}// 确定此子项想要有多大。如果此子项或先前的子项已指定weight权重则我们允许它使用所有可用空间如果需要我们稍后会缩小空间。final int usedHeight totalWeight 0 ? mTotalLength : 0;//测量子View的宽高measureChildBeforeLayout(child, i, widthMeasureSpec, 0,heightMeasureSpec, usedHeight);final int childHeight child.getMeasuredHeight();if (useExcessSpace) {// 恢复原始高度并记录我们为多余的子项分配了多少空间以便我们能够匹配精确测量的行为。lp.height 0;consumedExcessSpace childHeight;}final int totalLength mTotalLength;//更新当前总的高度mTotalLength Math.max(totalLength, totalLength childHeight lp.topMargin lp.bottomMargin getNextLocationOffset(child));if (useLargestChild) {//这个largestChildHeight可以理解成所有子View中的高度最大的View的高度主要是为了在当前View使用weight0但是父View的高度不确定的情况下确定子View的高度比如LinearLayout是wrap_content,largestChildHeight Math.max(childHeight, largestChildHeight);}}if ((baselineChildIndex 0) (baselineChildIndex i 1)) {mBaselineChildTop mTotalLength;}boolean matchWidthLocally false;if (widthMode ! MeasureSpec.EXACTLY lp.width LayoutParams.MATCH_PARENT) {// 线性布局的宽度将缩放并且至少有一个子视图表示它想要匹配我们的宽度。设置一个标志表示当我们知道我们的宽度时我们至少需要重新测量该视图。matchWidth true;matchWidthLocally true;}final int margin lp.leftMargin lp.rightMargin;final int measuredWidth child.getMeasuredWidth() margin;maxWidth Math.max(maxWidth, measuredWidth);childState combineMeasuredStates(childState, child.getMeasuredState());allFillParent allFillParent lp.width LayoutParams.MATCH_PARENT;if (lp.weight 0) {/** 计算最大宽度*/weightedMaxWidth Math.max(weightedMaxWidth,matchWidthLocally ? margin : measuredWidth);} else {alternativeMaxWidth Math.max(alternativeMaxWidth,matchWidthLocally ? margin : measuredWidth);}i getChildrenSkipCount(child, i);}从第一测量的源码得知其第一次测量主要是测量weight0的子View的宽高并为第二次测量做准备统计weight的和、统计已使用的高度(为weight能分配的高度做准备) 统计最大的子View的高度。 第二次测量 //remainingExcess为剩余可以为weight0的子View分配高度的总和int remainingExcess heightSize - mTotalLength (mAllowInconsistentMeasurement ? 0 : consumedExcessSpace); if (skippedMeasure|| ((sRemeasureWeightedChildren || remainingExcess ! 0) totalWeight 0.0f)) {//如果有weight0的子View。则走这个分支float remainingWeightSum mWeightSum 0.0f ? mWeightSum : totalWeight;mTotalLength 0;for (int i 0; i count; i) {final View child getVirtualChildAt(i);if (child null || child.getVisibility() View.GONE) {continue;}final LayoutParams lp (LayoutParams) child.getLayoutParams();final float childWeight lp.weight;if (childWeight 0) {// 按照权重计算每个weight0的子View的高度final int share (int) (childWeight * remainingExcess / remainingWeightSum);remainingExcess - share;remainingWeightSum - childWeight;final int childHeight;if (mUseLargestChild heightMode ! MeasureSpec.EXACTLY) {childHeight largestChildHeight;} else if (lp.height 0 (!mAllowInconsistentMeasurement|| heightMode MeasureSpec.EXACTLY)) {// This child needs to be laid out from scratch using// only its share of excess space.childHeight share;} else {// This child had some intrinsic height to which we// need to add its share of excess space.childHeight child.getMeasuredHeight() share;}//生成子View的高度MeasureSpec模式为精确final int childHeightMeasureSpec MeasureSpec.makeMeasureSpec(Math.max(0, childHeight), MeasureSpec.EXACTLY);final int childWidthMeasureSpec getChildMeasureSpec(widthMeasureSpec,mPaddingLeft mPaddingRight lp.leftMargin lp.rightMargin,lp.width);//重新测量子Viewchild.measure(childWidthMeasureSpec, childHeightMeasureSpec);// Child may now not fit in vertical dimension.childState combineMeasuredStates(childState, child.getMeasuredState() (MEASURED_STATE_MASKMEASURED_HEIGHT_STATE_SHIFT));}final int margin lp.leftMargin lp.rightMargin;final int measuredWidth child.getMeasuredWidth() margin;maxWidth Math.max(maxWidth, measuredWidth);boolean matchWidthLocally widthMode ! MeasureSpec.EXACTLY lp.width LayoutParams.MATCH_PARENT;alternativeMaxWidth Math.max(alternativeMaxWidth,matchWidthLocally ? margin : measuredWidth);allFillParent allFillParent lp.width LayoutParams.MATCH_PARENT;final int totalLength mTotalLength;mTotalLength Math.max(totalLength, totalLength child.getMeasuredHeight() lp.topMargin lp.bottomMargin getNextLocationOffset(child));}// Add in our paddingmTotalLength mPaddingTop mPaddingBottom;// TODO: Should we recompute the heightSpec based on the new total length?} else {alternativeMaxWidth Math.max(alternativeMaxWidth,weightedMaxWidth);// We have no limit, so make all weighted views as tall as the largest child.// Children will have already been measured once.if (useLargestChild heightMode ! MeasureSpec.EXACTLY) {for (int i 0; i count; i) {final View child getVirtualChildAt(i);if (child null || child.getVisibility() View.GONE) {continue;}final LinearLayout.LayoutParams lp (LinearLayout.LayoutParams) child.getLayoutParams();float childExtra lp.weight;if (childExtra 0) {child.measure(MeasureSpec.makeMeasureSpec(child.getMeasuredWidth(),MeasureSpec.EXACTLY),MeasureSpec.makeMeasureSpec(largestChildHeight,MeasureSpec.EXACTLY));}}}}
http://www.hkea.cn/news/14413782/

相关文章:

  • 网站速度慢如何做优化重庆美邦建网站
  • 焦作网站建设设计东莞招聘网最新招聘信息
  • 大连做网站优化哪家好织梦网站地图怎么做xml
  • jsp做网站用到什么技术网站使用费用
  • 电子商务网站建设的书临夏网站建设公司
  • 营销型企业网站怎么建站南宁seo网站排名优化公司
  • 迁西县住房和城乡规划建设局网站贵阳网站建设设计公司
  • 陕西城乡建设网站ppt模板百度网盘
  • 网站基础知识设计广告公司网站建设
  • 如何做网站卡密制作网站公司网址
  • 网站下一步工作怎么做vs连接数据库做网站
  • 制作网站软件不懂代码可以制作吗怎么开发网站平台
  • 网站优化工作安排如何开通属于自己的网站
  • 腾讯云学生怎么做网站的wordpress mysql设置
  • 网站开源程序公司网站做一下多少钱
  • 厦门建网站三合一网站建设多少钱
  • 如何推广网站话术wordpress内页长尾词排名
  • 建站行业新闻安徽省城乡与住房建设厅网站
  • 全州建设完小网站vi设计的概念
  • 阿里云虚拟主机可以做几个网站wordpress模板如何安装教程视频教程
  • 为了加强公司网站建设优化英语
  • 空间设计工作室网站WordPress修改页眉
  • html手机网站如何制作网站建站方案书
  • 家庭电影网站建设个人网站设计模板中文
  • 网站建设皿金手指谷哥壹柒做销售平台哪个网站好
  • 关于网站建设的论文题目长沙优化推广外包
  • 沈阳外贸网站建设wordpress修改媒体的路径
  • 做网络平台的网站有哪些免费高清视频在线观看
  • 昆明好的网站开发公司平面设计网上培训一般多少钱
  • win8.1 做网站服务器做框架模板的网站