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

如何知道网站开发语言wordpress主题伪静态

如何知道网站开发语言,wordpress主题伪静态,怎么做百度推广运营,wordpress 代码缓存当我们在使用到ScrollView和ListView的时候可能会出现显示不全的问题。那我们可以进行以下分析 ScrollView在测量子布局的时候会用UNSPECIFIED。通过源码观察#xff0c; 在ScrollView的onMeasure方法中 Overrideprotected void onMeasure(int widthMeasureSpec, int heightMe…当我们在使用到ScrollView和ListView的时候可能会出现显示不全的问题。那我们可以进行以下分析 ScrollView在测量子布局的时候会用UNSPECIFIED。通过源码观察 在ScrollView的onMeasure方法中 Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {super.onMeasure(widthMeasureSpec, heightMeasureSpec);if (!mFillViewport) {return;}final int heightMode MeasureSpec.getMode(heightMeasureSpec);if (heightMode MeasureSpec.UNSPECIFIED) {return;}if (getChildCount() 0) {final View child getChildAt(0);final int widthPadding;final int heightPadding;final int targetSdkVersion getContext().getApplicationInfo().targetSdkVersion;final FrameLayout.LayoutParams lp (LayoutParams) child.getLayoutParams();if (targetSdkVersion VERSION_CODES.M) {widthPadding mPaddingLeft mPaddingRight lp.leftMargin lp.rightMargin;heightPadding mPaddingTop mPaddingBottom lp.topMargin lp.bottomMargin;} else {widthPadding mPaddingLeft mPaddingRight;heightPadding mPaddingTop mPaddingBottom;}final int desiredHeight getMeasuredHeight() - heightPadding;if (child.getMeasuredHeight() desiredHeight) {final int childWidthMeasureSpec getChildMeasureSpec(widthMeasureSpec, widthPadding, lp.width);final int childHeightMeasureSpec MeasureSpec.makeMeasureSpec(desiredHeight, MeasureSpec.EXACTLY);child.measure(childWidthMeasureSpec, childHeightMeasureSpec);}}} 点击super.onMeasure()方法可以观察到进入了FrameLayout中 Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {int count getChildCount();final boolean measureMatchParentChildren MeasureSpec.getMode(widthMeasureSpec) ! MeasureSpec.EXACTLY ||MeasureSpec.getMode(heightMeasureSpec) ! MeasureSpec.EXACTLY;mMatchParentChildren.clear();int maxHeight 0;int maxWidth 0;int childState 0;for (int i 0; i count; i) {final View child getChildAt(i);if (mMeasureAllChildren || child.getVisibility() ! GONE) {measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);final LayoutParams lp (LayoutParams) child.getLayoutParams();maxWidth Math.max(maxWidth,child.getMeasuredWidth() lp.leftMargin lp.rightMargin);maxHeight Math.max(maxHeight,child.getMeasuredHeight() lp.topMargin lp.bottomMargin);childState combineMeasuredStates(childState, child.getMeasuredState());if (measureMatchParentChildren) {if (lp.width LayoutParams.MATCH_PARENT ||lp.height LayoutParams.MATCH_PARENT) {mMatchParentChildren.add(child);}}}}// Account for padding toomaxWidth getPaddingLeftWithForeground() getPaddingRightWithForeground();maxHeight getPaddingTopWithForeground() getPaddingBottomWithForeground();// Check against our minimum height and widthmaxHeight Math.max(maxHeight, getSuggestedMinimumHeight());maxWidth Math.max(maxWidth, getSuggestedMinimumWidth());// Check against our foregrounds minimum height and widthfinal Drawable drawable getForeground();if (drawable ! null) {maxHeight Math.max(maxHeight, drawable.getMinimumHeight());maxWidth Math.max(maxWidth, drawable.getMinimumWidth());}setMeasuredDimension(resolveSizeAndState(maxWidth, widthMeasureSpec, childState),resolveSizeAndState(maxHeight, heightMeasureSpec,childState MEASURED_HEIGHT_STATE_SHIFT));count mMatchParentChildren.size();if (count 1) {for (int i 0; i count; i) {final View child mMatchParentChildren.get(i);final MarginLayoutParams lp (MarginLayoutParams) child.getLayoutParams();final int childWidthMeasureSpec;if (lp.width LayoutParams.MATCH_PARENT) {final int width Math.max(0, getMeasuredWidth()- getPaddingLeftWithForeground() - getPaddingRightWithForeground()- lp.leftMargin - lp.rightMargin);childWidthMeasureSpec MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);} else {childWidthMeasureSpec getChildMeasureSpec(widthMeasureSpec,getPaddingLeftWithForeground() getPaddingRightWithForeground() lp.leftMargin lp.rightMargin,lp.width);}final int childHeightMeasureSpec;if (lp.height LayoutParams.MATCH_PARENT) {final int height Math.max(0, getMeasuredHeight()- getPaddingTopWithForeground() - getPaddingBottomWithForeground()- lp.topMargin - lp.bottomMargin);childHeightMeasureSpec MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);} else {childHeightMeasureSpec getChildMeasureSpec(heightMeasureSpec,getPaddingTopWithForeground() getPaddingBottomWithForeground() lp.topMargin lp.bottomMargin,lp.height);}child.measure(childWidthMeasureSpec, childHeightMeasureSpec);}}}里面有个measureChildWithMargins方法 protected void measureChildWithMargins(View child,int parentWidthMeasureSpec, int widthUsed,int parentHeightMeasureSpec, int heightUsed) {final MarginLayoutParams lp (MarginLayoutParams) child.getLayoutParams();final int childWidthMeasureSpec getChildMeasureSpec(parentWidthMeasureSpec,mPaddingLeft mPaddingRight lp.leftMargin lp.rightMargin widthUsed, lp.width);final int childHeightMeasureSpec getChildMeasureSpec(parentHeightMeasureSpec,mPaddingTop mPaddingBottom lp.topMargin lp.bottomMargin heightUsed, lp.height);child.measure(childWidthMeasureSpec, childHeightMeasureSpec);}这个时候发现ScrollView有重写这个方法 Overrideprotected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed,int parentHeightMeasureSpec, int heightUsed) {final MarginLayoutParams lp (MarginLayoutParams) child.getLayoutParams();final int childWidthMeasureSpec getChildMeasureSpec(parentWidthMeasureSpec,mPaddingLeft mPaddingRight lp.leftMargin lp.rightMargin widthUsed, lp.width);final int usedTotal mPaddingTop mPaddingBottom lp.topMargin lp.bottomMargin heightUsed;final int childHeightMeasureSpec MeasureSpec.makeSafeMeasureSpec(Math.max(0, MeasureSpec.getSize(parentHeightMeasureSpec) - usedTotal),MeasureSpec.UNSPECIFIED);child.measure(childWidthMeasureSpec, childHeightMeasureSpec);}其中childHeightMeasureSpec的模式是MeasureSpec.UNSPECIFIED。这个表示尽可能的大很少能用到。 而我们的ListView也会调用onMeaure方法 Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {// Sets up mListPaddingsuper.onMeasure(widthMeasureSpec, heightMeasureSpec);final int widthMode MeasureSpec.getMode(widthMeasureSpec);final int heightMode MeasureSpec.getMode(heightMeasureSpec);int widthSize MeasureSpec.getSize(widthMeasureSpec);int heightSize MeasureSpec.getSize(heightMeasureSpec);int childWidth 0;int childHeight 0;int childState 0;mItemCount mAdapter null ? 0 : mAdapter.getCount();if (mItemCount 0 (widthMode MeasureSpec.UNSPECIFIED|| heightMode MeasureSpec.UNSPECIFIED)) {final View child obtainView(0, mIsScrap);// Lay out child directly against the parent measure spec so that// we can obtain exected minimum width and height.measureScrapChild(child, 0, widthMeasureSpec, heightSize);childWidth child.getMeasuredWidth();childHeight child.getMeasuredHeight();childState combineMeasuredStates(childState, child.getMeasuredState());if (recycleOnMeasure() mRecycler.shouldRecycleViewType(((LayoutParams) child.getLayoutParams()).viewType)) {mRecycler.addScrapView(child, 0);}}if (widthMode MeasureSpec.UNSPECIFIED) {widthSize mListPadding.left mListPadding.right childWidth getVerticalScrollbarWidth();} else {widthSize | (childState MEASURED_STATE_MASK);}if (heightMode MeasureSpec.UNSPECIFIED) {heightSize mListPadding.top mListPadding.bottom childHeight getVerticalFadingEdgeLength() * 2;}if (heightMode MeasureSpec.AT_MOST) {// TODO: after first layout we should maybe start at the first visible position, not 0heightSize measureHeightOfChildren(widthMeasureSpec, 0, NO_POSITION, heightSize, -1);}setMeasuredDimension(widthSize, heightSize);mWidthMeasureSpec widthMeasureSpec;}其中的heightMeasureSpec也就是我们在ScrollView中child.measure(childWidthMeasureSpec, childHeightMeasureSpec);在传递过来的。所以也是模式为MeasureSpec.UNSPECIFIED。而当heightMode MeasureSpec.UNSPECIFIED时会调用 if (heightMode MeasureSpec.UNSPECIFIED) {heightSize mListPadding.top mListPadding.bottom childHeight getVerticalFadingEdgeLength() * 2;}这样在heightSize mListPadding.top mListPadding.bottom childHeight getVerticalFadingEdgeLength() * 2只是加了一个childHeight 所以展示的只有一个item的大小。 所以要解决这个问题应该让listView进入heightMode MeasureSpec.AT_MOST里。 public class MyListView extends ListView {public MyListView(Context context) {super(context);}public MyListView(Context context, AttributeSet attrs) {super(context, attrs);}public MyListView(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);}Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {//解决显示不全的问题heightMeasureSpecMeasureSpec.makeMeasureSpec(Integer.MAX_VALUE2,MeasureSpec.AT_MOST);super.onMeasure(widthMeasureSpec, heightMeasureSpec);} } 网上有的博客换成MyListView这么做就实现了那么为什么呢 首先当我们的模式为AT_MOST if (heightMode MeasureSpec.AT_MOST) {// TODO: after first layout we should maybe start at the first visible position, not 0heightSize measureHeightOfChildren(widthMeasureSpec, 0, NO_POSITION, heightSize, -1);}调用ListView的measureHeightOfChildren UnsupportedAppUsage(maxTargetSdk Build.VERSION_CODES.P, trackingBug 115609023)final int measureHeightOfChildren(int widthMeasureSpec, int startPosition, int endPosition,int maxHeight, int disallowPartialChildPosition) {final ListAdapter adapter mAdapter;if (adapter null) {return mListPadding.top mListPadding.bottom;}// Include the padding of the listint returnedHeight mListPadding.top mListPadding.bottom;final int dividerHeight mDividerHeight;// The previous height value that was less than maxHeight and contained// no partial childrenint prevHeightWithoutPartialChild 0;int i;View child;// mItemCount - 1 since endPosition parameter is inclusiveendPosition (endPosition NO_POSITION) ? adapter.getCount() - 1 : endPosition;final AbsListView.RecycleBin recycleBin mRecycler;final boolean recyle recycleOnMeasure();final boolean[] isScrap mIsScrap;for (i startPosition; i endPosition; i) {child obtainView(i, isScrap);measureScrapChild(child, i, widthMeasureSpec, maxHeight);if (i 0) {// Count the divider for all but one childreturnedHeight dividerHeight;}// Recycle the view before we possibly return from the methodif (recyle recycleBin.shouldRecycleViewType(((LayoutParams) child.getLayoutParams()).viewType)) {recycleBin.addScrapView(child, -1);}returnedHeight child.getMeasuredHeight();if (returnedHeight maxHeight) {// We went over, figure out which height to return. If returnedHeight maxHeight,// then the ith position did not fit completely.return (disallowPartialChildPosition 0) // Disallowing is enabled ( -1) (i disallowPartialChildPosition) // Weve past the min pos (prevHeightWithoutPartialChild 0) // We have a prev height (returnedHeight ! maxHeight) // ith child did not fit completely? prevHeightWithoutPartialChild: maxHeight;}if ((disallowPartialChildPosition 0) (i disallowPartialChildPosition)) {prevHeightWithoutPartialChild returnedHeight;}}// At this point, we went through the range of children, and they each// completely fit, so return the returnedHeightreturn returnedHeight;}因为returnedHeight一直在累加这样我们让maxHeight为最大值这样他就不会进入if (returnedHeight maxHeight) 而是返回returnedHeight。 onMeasure方法中的widthMeasureSpec和heightMeasureSpec会包含两个信息第一个信息是模式2位第二个信息是值30位。一共32位 而这里为什么Integer.MAX_VALUE 要右移两位 public static int makeMeasureSpec(IntRange(from 0, to (1 MeasureSpec.MODE_SHIFT) - 1) int size,MeasureSpecMode int mode) {if (sUseBrokenMakeMeasureSpec) {return size mode;} else {return (size ~MODE_MASK) | (mode MODE_MASK);}}因为Integer.MAX_VALUE右移两位等于一个30位的值这样执行makeMeasureSpec就可以构建成一个32位的值。这样去替换ListView的heightMeasureSpec即可。 /*** A constant holding the maximum value an {code int} can* have, 2sup31/sup-1.*/Native public static final int MAX_VALUE 0x7fffffff;
http://www.w-s-a.com/news/957536/

相关文章:

  • 可以做app的网站logo设计在线生成免费标小智
  • 网站变更备案做酒类网站
  • 网站必须要备案吗东莞市非凡网站建设
  • 太原建网站公司网站设计的流程是怎样的
  • 网站开发交易平台北京网站建设的价格低
  • 捷克注册公司网站搜索引擎广告推广
  • 网站的实用性青岛九二网络科技有限公司
  • 广东备案网站网站反链如何做
  • 做网站的实施过程企业建设H5响应式网站的5大好处6
  • ps制作个人网站首页景安搭建wordpress
  • 常德建设网站制作网站建设推广是什么工作
  • 长春服务好的网站建设百度推广话术全流程
  • 做的网站浏览的越多越挣钱基于jsp的网站开发开题报告
  • 好的做问卷调查的网站好网站调用时间
  • 广州微网站建设平台阿里云国外服务器
  • 如何把做好的网站代码变成网页wordpress shortcode土豆 视频
  • 网站改版竞品分析怎么做中山网站建设文化价格
  • 玉林市网站开发公司电话做网站空间 阿里云
  • 南充做网站略奥网络免费的正能量视频素材网站
  • 电子商务网站开发的基本原则汕头网站制作流程
  • 网站访问量突然增加合肥宣传片制作公司六维时空
  • 建设购物网站流程图怎么找网站
  • 阿里云部署多个网站制作小程序网站源码
  • 博罗东莞网站建设网站免费源代码
  • 网站规划与设计范文桂平网站建设
  • 网站备案号密码wordpress邮箱发送信息错误
  • 模板的网站都有哪些关键词搜索工具爱站网
  • 鲜花网站建设的利息分析企业网站建设方案书
  • 深圳网站平台石家庄做商城网站的公司
  • 微网站营销是什么私人订制网站有哪些