zoukankan      html  css  js  c++  java
  • android measure

    几个有用的方法

    求一个view的宽度

    public static void measureView(View child) {
            ViewGroup.LayoutParams p = child.getLayoutParams();
            if (p == null) {
                p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            }
    
            int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0 + 0, p.width);
            int lpHeight = p.height;
            int childHeightSpec;
            if (lpHeight > 0) {
                childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY);
            } else {
                childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
            }
            child.measure(childWidthSpec, childHeightSpec);
        }

    调用过程

    ViewUtil.measureView(mHeaderView);
    mHeadViewHeight = mHeaderView.getMeasuredHeight();
  • 相关阅读:
    K8S calico
    K9S之glusterfs
    kubeadm安装报错
    创建crd和cr
    分布式学习汇总
    容器常见问题分析
    项目迁移到k8s平台流程
    K8S storageclass
    awk命令
    K8S headless service服务详解
  • 原文地址:https://www.cnblogs.com/wjw334/p/4458284.html
Copyright © 2011-2022 走看看