android.widget.ImageButton# getMeasuredHeight ( ) 源码实例Demo

下面列出了android.widget.ImageButton# getMeasuredHeight ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: DateTimePicker   文件: DayPickerView.java
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    final ImageButton leftButton;
    final ImageButton rightButton;

    if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL) {
        leftButton = mNextButton;
        rightButton = mPrevButton;
    } else {
        leftButton = mPrevButton;
        rightButton = mNextButton;
    }

    final int width = right - left;
    final int height = bottom - top;
    mViewPager.layout(0, 0, width, height);

    final SimpleMonthView monthView = (SimpleMonthView) mViewPager.getChildAt(0);
    final int monthHeight = monthView.getMonthHeight();
    final int cellWidth = monthView.getCellWidth();

    // Vertically center the previous/next buttons within the month
    // header, horizontally center within the day cell.
    final int leftDW = leftButton.getMeasuredWidth();
    final int leftDH = leftButton.getMeasuredHeight();
    final int leftIconTop = monthView.getPaddingTop() + (monthHeight - leftDH) / 2;
    final int leftIconLeft = monthView.getPaddingLeft() + (cellWidth - leftDW) / 2;
    leftButton.layout(leftIconLeft, leftIconTop, leftIconLeft + leftDW, leftIconTop + leftDH);

    final int rightDW = rightButton.getMeasuredWidth();
    final int rightDH = rightButton.getMeasuredHeight();
    final int rightIconTop = monthView.getPaddingTop() + (monthHeight - rightDH) / 2;
    final int rightIconRight = width - monthView.getPaddingRight() - (cellWidth - rightDW) / 2;
    rightButton.layout(rightIconRight - rightDW, rightIconTop,
            rightIconRight, rightIconTop + rightDH);
}
 
源代码2 项目: date_picker_converter   文件: DayPickerGroup.java
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    final ImageButton leftButton;
    final ImageButton rightButton;
    if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL) {
        leftButton = nextButton;
        rightButton = prevButton;
    } else {
        leftButton = prevButton;
        rightButton = nextButton;
    }

    final int width = right - left;
    final int height = bottom - top;
    dayPickerView.layout(0, 0, width, height);

    final SimpleMonthView monthView = (SimpleMonthView) dayPickerView.getChildAt(0);
    final int monthHeight = monthView.getMonthHeight();
    final int cellWidth = monthView.getCellWidth();
    final int edgePadding = monthView.getEdgePadding();

    // Vertically center the previous/next buttons within the month
    // header, horizontally center within the day cell.
    final int leftDW = leftButton.getMeasuredWidth();
    final int leftDH = leftButton.getMeasuredHeight();
    final int leftIconTop = monthView.getPaddingTop() + (monthHeight - leftDH) / 2;
    final int leftIconLeft = edgePadding + (cellWidth - leftDW) / 2;
    leftButton.layout(leftIconLeft, leftIconTop, leftIconLeft + leftDW, leftIconTop + leftDH);

    final int rightDW = rightButton.getMeasuredWidth();
    final int rightDH = rightButton.getMeasuredHeight();
    final int rightIconTop = monthView.getPaddingTop() + (monthHeight - rightDH) / 2;
    final int rightIconRight = width - edgePadding - (cellWidth - rightDW) / 2 - 2;
    rightButton.layout(rightIconRight - rightDW, rightIconTop,
            rightIconRight, rightIconTop + rightDH);
}
 
源代码3 项目: SublimePicker   文件: DayPickerView.java
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    final ImageButton leftButton;
    final ImageButton rightButton;
    if (SUtils.isLayoutRtlCompat(this)) {
        leftButton = mNextButton;
        rightButton = mPrevButton;
    } else {
        leftButton = mPrevButton;
        rightButton = mNextButton;
    }

    final int width = right - left;
    final int height = bottom - top;
    mViewPager.layout(0, 0, width, height);

    final SimpleMonthView monthView = (SimpleMonthView) mViewPager.getChildAt(0)
            .findViewById(R.id.month_view);
    final int monthHeight = monthView.getMonthHeight();
    final int cellWidth = monthView.getCellWidth();

    // Vertically center the previous/next buttons within the month
    // header, horizontally center within the day cell.
    final int leftDW = leftButton.getMeasuredWidth();
    final int leftDH = leftButton.getMeasuredHeight();
    final int leftIconTop = monthView.getPaddingTop() + (monthHeight - leftDH) / 2;
    final int leftIconLeft = monthView.getPaddingLeft() + (cellWidth - leftDW) / 2;
    leftButton.layout(leftIconLeft, leftIconTop, leftIconLeft + leftDW, leftIconTop + leftDH);

    final int rightDW = rightButton.getMeasuredWidth();
    final int rightDH = rightButton.getMeasuredHeight();
    final int rightIconTop = monthView.getPaddingTop() + (monthHeight - rightDH) / 2;
    final int rightIconRight = width - monthView.getPaddingRight() - (cellWidth - rightDW) / 2;
    rightButton.layout(rightIconRight - rightDW, rightIconTop,
            rightIconRight, rightIconTop + rightDH);
}
 
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    final ImageButton leftButton;
    final ImageButton rightButton;
    if (ViewCompatUtils.isLayoutRtl(this)) {
        leftButton = mNextButton;
        rightButton = mPrevButton;
    } else {
        leftButton = mPrevButton;
        rightButton = mNextButton;
    }
    PickerThemeUtils.setNavButtonDrawable(getContext(), leftButton, rightButton,
            mAdapter.getMonthTextAppearance());

    final int width = right - left;
    final int height = bottom - top;
    mViewPager.layout(0, 0, width, height);

    final SimpleMonthView monthView = (SimpleMonthView) mViewPager.getChildAt(0);
    final int monthHeight = monthView.getMonthHeight();
    final int cellWidth = monthView.getCellWidth();

    // Vertically center the previous/next buttons within the month
    // header, horizontally center within the day cell.
    final int leftDW = leftButton.getMeasuredWidth();
    final int leftDH = leftButton.getMeasuredHeight();
    final int leftIconTop = monthView.getPaddingTop() + (monthHeight - leftDH) / 2;
    final int leftIconLeft = monthView.getPaddingLeft() + (cellWidth - leftDW) / 2;
    leftButton.layout(leftIconLeft, leftIconTop, leftIconLeft + leftDW, leftIconTop + leftDH);

    final int rightDW = rightButton.getMeasuredWidth();
    final int rightDH = rightButton.getMeasuredHeight();
    final int rightIconTop = monthView.getPaddingTop() + (monthHeight - rightDH) / 2;
    final int rightIconRight = width - monthView.getPaddingRight() - (cellWidth - rightDW) / 2;
    rightButton.layout(rightIconRight - rightDW, rightIconTop,
            rightIconRight, rightIconTop + rightDH);
}
 
源代码5 项目: MaterialDateTimePicker   文件: DayPickerGroup.java
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    final ImageButton leftButton;
    final ImageButton rightButton;
    if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL) {
        leftButton = nextButton;
        rightButton = prevButton;
    } else {
        leftButton = prevButton;
        rightButton = nextButton;
    }

    final int topMargin = controller.getVersion() == DatePickerDialog.Version.VERSION_1
            ? 0
            : getContext().getResources().getDimensionPixelSize(R.dimen.mdtp_date_picker_view_animator_padding_v2);
    final int width = right - left;
    final int height = bottom - top;
    dayPickerView.layout(0, topMargin, width, height);

    final SimpleMonthView monthView = (SimpleMonthView) dayPickerView.getChildAt(0);
    final int monthHeight = monthView.getMonthHeight();
    final int cellWidth = monthView.getCellWidth();
    final int edgePadding = monthView.getEdgePadding();

    // Vertically center the previous/next buttons within the month
    // header, horizontally center within the day cell.
    final int leftDW = leftButton.getMeasuredWidth();
    final int leftDH = leftButton.getMeasuredHeight();
    final int leftIconTop = topMargin + monthView.getPaddingTop() + (monthHeight - leftDH) / 2;
    final int leftIconLeft = edgePadding + (cellWidth - leftDW) / 2;
    leftButton.layout(leftIconLeft, leftIconTop, leftIconLeft + leftDW, leftIconTop + leftDH);

    final int rightDW = rightButton.getMeasuredWidth();
    final int rightDH = rightButton.getMeasuredHeight();
    final int rightIconTop = topMargin + monthView.getPaddingTop() + (monthHeight - rightDH) / 2;
    final int rightIconRight = width - edgePadding - (cellWidth - rightDW) / 2 - 2;
    rightButton.layout(rightIconRight - rightDW, rightIconTop,
            rightIconRight, rightIconTop + rightDH);
}