android.widget.Button.onMeasure()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中android.widget.Button.onMeasure()方法的一些代码示例,展示了Button.onMeasure()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.onMeasure()方法的具体详情如下:
包路径:android.widget.Button
类名称:Button
方法名:onMeasure

Button.onMeasure介绍

暂无

代码示例

代码示例来源:origin: ZieIony/Carbon

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  if (getMeasuredWidth() > maxWidth || getMeasuredHeight() > maxHeight) {
    if (getMeasuredWidth() > maxWidth)
      widthMeasureSpec = MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.EXACTLY);
    if (getMeasuredHeight() > maxHeight)
      heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.EXACTLY);
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }
}

代码示例来源:origin: lygttpod/AndroidCustomView

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  int width = MeasureSpec.getSize(widthMeasureSpec);
  int height = MeasureSpec.getSize(heightMeasureSpec);
  mWidth = width;
  mHeight = height;
  centerX = mWidth / 2;
  centerY = mHeight / 2;
  radius = mHeight / 8;
  Log.d("allen", "onMeasure: " + centerX);
}

代码示例来源:origin: derry/delion

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  int desiredWidth = Math.max(
      mIncognitoDrawable.getIntrinsicWidth(), mNormalDrawable.getIntrinsicWidth());
  desiredWidth += getPaddingLeft() + getPaddingRight();
  widthMeasureSpec = MeasureSpec.makeMeasureSpec(desiredWidth, MeasureSpec.EXACTLY);
  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

代码示例来源:origin: jiang111/CProgressButton

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  mWidth = getWidth() - getPaddingLeft() - getPaddingRight();
  mHeight = getHeight() - getPaddingTop() - getPaddingRight();
}

相关文章

Button类方法