Example usage for android.view ViewGroup getPaddingTop

List of usage examples for android.view ViewGroup getPaddingTop

Introduction

In this page you can find the example usage for android.view ViewGroup getPaddingTop.

Prototype

public int getPaddingTop() 

Source Link

Document

Returns the top padding of this view.

Usage

From source file:com.waz.zclient.pages.main.participants.dialog.ParticipantsDialogFragment.java

private void adjustAccordingToAnchor() {
    Bundle bundle = getArguments();/*from  w  w w.  j a  va  2  s  .co m*/
    if (bundle == null || getView() == null) {
        return;
    }
    View view = getView();
    ViewGroup viewGroup = (ViewGroup) view.getParent();
    Rect rect = bundle.getParcelable(ARG_ANCHOR_RECT);
    int posX = bundle.getInt(ARG_POS_X);
    int posY = bundle.getInt(ARG_POS_Y);

    final int widthSpec = View.MeasureSpec.makeMeasureSpec(
            viewGroup.getMeasuredWidth() - viewGroup.getPaddingLeft() - viewGroup.getPaddingRight(),
            View.MeasureSpec.AT_MOST);
    final int heightSpec = View.MeasureSpec.makeMeasureSpec(
            viewGroup.getMeasuredHeight() - viewGroup.getPaddingTop() - viewGroup.getPaddingBottom(),
            View.MeasureSpec.AT_MOST);
    view.measure(widthSpec, heightSpec);

    ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) dialogFrameLayout
            .getLayoutParams();
    int rootHeight = dialogFrameLayout.getMeasuredHeight();
    int rootWidth = dialogFrameLayout.getMeasuredWidth();

    int dialogHeight = rootHeight + layoutParams.bottomMargin + layoutParams.topMargin;
    int dialogWidth = rootWidth + layoutParams.leftMargin + layoutParams.rightMargin;

    setDialogPosition(rect, posX, posY, dialogWidth, dialogHeight);
}