zoukankan      html  css  js  c++  java
  • 方形布局SquareLayout

     1 public class SquareLayout extends RelativeLayout {
     2     public SquareLayout(Context context, AttributeSet attrs, int defStyle) {
     3         super(context, attrs, defStyle);
     4     }
     5 
     6     public SquareLayout(Context context, AttributeSet attrs) {
     7         super(context, attrs);
     8     }
     9 
    10     public SquareLayout(Context context) {
    11         super(context);
    12     }
    13 
    14     @Override
    15     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    16         setMeasuredDimension(getDefaultSize(0, widthMeasureSpec),
    17                 getDefaultSize(0, heightMeasureSpec));
    18         int childWidthSize = getMeasuredWidth();
    19         int childHeightSize = getMeasuredHeight();
    20         // 高度和宽度一样
    21         heightMeasureSpec = widthMeasureSpec = MeasureSpec.makeMeasureSpec(
    22                 childWidthSize, MeasureSpec.EXACTLY);
    23         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    24     }
    25 }
  • 相关阅读:
    单选多选样式写法
    深拷贝方法
    防抖和节流的实现
    yarn 常用指令
    前端性能监控
    全表 or 索引
    Order by
    DINSTINCT
    智力题
    概率问题
  • 原文地址:https://www.cnblogs.com/lavalike/p/5112618.html
Copyright © 2011-2022 走看看