android.widget.EditText.layout()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(142)

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

EditText.layout介绍

暂无

代码示例

代码示例来源:origin: rey5137/material

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
  int childLeft = getPaddingLeft();
  int childRight = r - l - getPaddingRight();
  int childTop = getPaddingTop();
  int childBottom = b - t - getPaddingBottom();
  
  if(mLabelView != null){
    mLabelView.layout(childLeft, childTop, childRight, childTop + mLabelView.getMeasuredHeight());
    childTop += mLabelView.getMeasuredHeight();
  }
  
  if(mSupportView != null){
    mSupportView.layout(childLeft, childBottom - mSupportView.getMeasuredHeight(), childRight, childBottom);
    childBottom -= mSupportView.getMeasuredHeight();
  }
  
  mInputView.layout(childLeft, childTop, childRight, childBottom);
}

代码示例来源:origin: forkachild/reel-search-android

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
  final int left = getPaddingLeft();
  final int top = getPaddingTop();
  final int right = getMeasuredWidth() - getPaddingRight();
  final int bottom = getMeasuredHeight() - getPaddingBottom();
  // Layout the RecyclerView child spanning the whole view
  mRecyclerView.layout(left, top, right, bottom);
  // Calculations
  final int halfEditTextHeight = mEditText.getMeasuredHeight() / 2;
  final int centerY = (top + bottom) / 2;
  // Layout the EditText at the center
  mEditText.layout(left, centerY - halfEditTextHeight, right, centerY + halfEditTextHeight);
}

代码示例来源:origin: halzhang/EverExample

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
  if (!mHasSelectorWheel) {
    super.onLayout(changed, left, top, right, bottom);
    return;
  }
  final int msrdWdth = getMeasuredWidth();
  final int msrdHght = getMeasuredHeight();
  // Input text centered horizontally.
  final int inptTxtMsrdWdth = mInputText.getMeasuredWidth();
  final int inptTxtMsrdHght = mInputText.getMeasuredHeight();
  final int inptTxtLeft = (msrdWdth - inptTxtMsrdWdth) / 2;
  final int inptTxtTop = (msrdHght - inptTxtMsrdHght) / 2;
  final int inptTxtRight = inptTxtLeft + inptTxtMsrdWdth;
  final int inptTxtBottom = inptTxtTop + inptTxtMsrdHght;
  mInputText.layout(inptTxtLeft, inptTxtTop, inptTxtRight, inptTxtBottom);
  if (changed) {
    // need to do all this when we know our size
    initializeSelectorWheel();
    initializeFadingEdges();
    mTopSelectionDividerTop = (getHeight() - mSelectionDividersDistance) / 2
        - mSelectionDividerHeight;
    mBottomSelectionDividerBottom = mTopSelectionDividerTop + 2 * mSelectionDividerHeight
        + mSelectionDividersDistance;
  }
}

代码示例来源:origin: MiEcosystem/mijiaSDK

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
  if (!mHasSelectorWheel) {
    super.onLayout(changed, left, top, right, bottom);
    return;
  }
  final int msrdWdth = getMeasuredWidth();
  final int msrdHght = getMeasuredHeight();
  // Input text centered horizontally.
  final int inptTxtMsrdWdth = mInputText.getMeasuredWidth();
  final int inptTxtMsrdHght = mInputText.getMeasuredHeight();
  final int inptTxtLeft = (msrdWdth - inptTxtMsrdWdth) / 2;
  final int inptTxtTop = (msrdHght - inptTxtMsrdHght) / 2;
  final int inptTxtRight = inptTxtLeft + inptTxtMsrdWdth;
  final int inptTxtBottom = inptTxtTop + inptTxtMsrdHght;
  mInputText.layout(inptTxtLeft, inptTxtTop, inptTxtRight, inptTxtBottom);
  if (changed) {
    // need to do all this when we know our size
    initializeSelectorWheel();
    initializeFadingEdges();
    mTopSelectionDividerTop = (getHeight() - mSelectionDividersDistance) / 2
        - mSelectionDividerHeight;
    mBottomSelectionDividerBottom = mTopSelectionDividerTop + 2 * mSelectionDividerHeight
        + mSelectionDividersDistance;
  }
}

代码示例来源:origin: ShawnLin013/NumberPicker

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
  final int msrdWdth = getMeasuredWidth();
  final int msrdHght = getMeasuredHeight();
  // Input text centered horizontally.
  final int inptTxtMsrdWdth = mSelectedText.getMeasuredWidth();
  final int inptTxtMsrdHght = mSelectedText.getMeasuredHeight();
  final int inptTxtLeft = (msrdWdth - inptTxtMsrdWdth) / 2;
  final int inptTxtTop = (msrdHght - inptTxtMsrdHght) / 2;
  final int inptTxtRight = inptTxtLeft + inptTxtMsrdWdth;
  final int inptTxtBottom = inptTxtTop + inptTxtMsrdHght;
  mSelectedText.layout(inptTxtLeft, inptTxtTop, inptTxtRight, inptTxtBottom);
  mSelectedTextCenterX = mSelectedText.getX() + mSelectedText.getMeasuredWidth() / 2;
  mSelectedTextCenterY = mSelectedText.getY() + mSelectedText.getMeasuredHeight() / 2;
  if (changed) {
    // need to do all this when we know our size
    initializeSelectorWheel();
    initializeFadingEdges();
    final int dividerDistance = 2 * mDividerThickness + mDividerDistance;
    if (isHorizontalMode()) {
      mLeftDividerLeft = (getWidth() - mDividerDistance) / 2 - mDividerThickness;
      mRightDividerRight = mLeftDividerLeft + dividerDistance;
    } else {
      mTopDividerTop = (getHeight() - mDividerDistance) / 2 - mDividerThickness;
      mBottomDividerBottom = mTopDividerTop + dividerDistance;
    }
  }
}

相关文章

微信公众号

最新文章

更多

EditText类方法