Java Code Examples for android.widget.ImageButton#getMeasuredHeight()

The following examples show how to use android.widget.ImageButton#getMeasuredHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DayPickerView.java    From DateTimePicker with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 2
Source File: DayPickerGroup.java    From date_picker_converter with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 3
Source File: DayPickerView.java    From SublimePicker with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 4
Source File: DayPickerView.java    From AppCompat-Extension-Library with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 5
Source File: DayPickerGroup.java    From MaterialDateTimePicker with Apache License 2.0 5 votes vote down vote up
@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);
}