Example usage for android.content.res TypedArray getDimensionPixelOffset

List of usage examples for android.content.res TypedArray getDimensionPixelOffset

Introduction

In this page you can find the example usage for android.content.res TypedArray getDimensionPixelOffset.

Prototype

public int getDimensionPixelOffset(@StyleableRes int index, int defValue) 

Source Link

Document

Retrieve a dimensional unit attribute at index for use as an offset in raw pixels.

Usage

From source file:com.xlf.nrl.CircleProgressBar.java

private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, defStyleAttr, 0);

    final float density = getContext().getResources().getDisplayMetrics().density;

    mBackGroundColor = a.getColor(R.styleable.CircleProgressBar_background_color, DEFAULT_CIRCLE_BG_LIGHT);

    mProgressColor = a.getColor(R.styleable.CircleProgressBar_progress_color, DEFAULT_CIRCLE_COLOR);
    mColors = new int[] { mProgressColor };

    mInnerRadius = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_inner_radius, -1);

    mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_progress_stoke_width,
            (int) (STROKE_WIDTH_LARGE * density));
    mArrowWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_arrow_width, -1);
    mArrowHeight = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_arrow_height, -1);
    mTextSize = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_progress_text_size,
            (int) (DEFAULT_TEXT_SIZE * density));
    mTextColor = a.getColor(R.styleable.CircleProgressBar_progress_text_color, Color.BLACK);

    mShowArrow = a.getBoolean(R.styleable.CircleProgressBar_show_arrow, true);
    mCircleBackgroundEnabled = a.getBoolean(R.styleable.CircleProgressBar_enable_circle_background, true);

    mProgress = a.getInt(R.styleable.CircleProgressBar_progress, 0);
    mMax = a.getInt(R.styleable.CircleProgressBar_max, 100);
    int textVisible = a.getInt(R.styleable.CircleProgressBar_progress_text_visibility, 1);
    if (textVisible != 1) {
        mIfDrawText = true;/* w  ww .j  ava 2 s.  co m*/
    }

    mTextPaint = new Paint();
    mTextPaint.setStyle(Paint.Style.FILL);
    mTextPaint.setColor(mTextColor);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setAntiAlias(true);
    a.recycle();
    mProgressDrawable = new MaterialProgressDrawable(getContext(), this);
    super.setImageDrawable(mProgressDrawable);
}

From source file:cn.com.elex.social_life.support.view.cjj.CircleProgressBar.java

private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, defStyleAttr, 0);

    final float density = getContext().getResources().getDisplayMetrics().density;

    mBackGroundColor = a.getColor(R.styleable.CircleProgressBar_mlpb_background_color, DEFAULT_CIRCLE_BG_LIGHT);

    mProgressColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_color, DEFAULT_CIRCLE_BG_LIGHT);
    mColors = new int[] { mProgressColor };

    mInnerRadius = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_inner_radius, -1);

    mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_stoke_width,
            (int) (STROKE_WIDTH_LARGE * density));
    mArrowWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_width, -1);
    mArrowHeight = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_height, -1);
    mTextSize = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_text_size,
            (int) (DEFAULT_TEXT_SIZE * density));
    mTextColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_text_color, Color.BLACK);

    mShowArrow = a.getBoolean(R.styleable.CircleProgressBar_mlpb_show_arrow, false);
    mCircleBackgroundEnabled = a.getBoolean(R.styleable.CircleProgressBar_mlpb_enable_circle_background, true);

    mProgress = a.getInt(R.styleable.CircleProgressBar_mlpb_progress, 0);
    mMax = a.getInt(R.styleable.CircleProgressBar_mlpb_max, 100);
    int textVisible = a.getInt(R.styleable.CircleProgressBar_mlpb_progress_text_visibility, 1);
    if (textVisible != 1) {
        mIfDrawText = true;/*from   w  ww  . j av a  2  s .  c o  m*/
    }

    mTextPaint = new Paint();
    mTextPaint.setStyle(Paint.Style.FILL);
    mTextPaint.setColor(mTextColor);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setAntiAlias(true);
    a.recycle();
    mProgressDrawable = new MaterialProgressDrawable(getContext(), this);
    super.setImageDrawable(mProgressDrawable);
}

From source file:cc.chenghong.vkagetorder.material.CircleProgressBar.java

private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, defStyleAttr, 0);

    final float density = getContext().getResources().getDisplayMetrics().density;

    mBackGroundColor = a.getColor(R.styleable.CircleProgressBar_mlpb_background_color, DEFAULT_CIRCLE_BG_LIGHT);

    mProgressColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_color, DEFAULT_CIRCLE_BG_LIGHT);
    mColors = new int[] { mProgressColor };

    mInnerRadius = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_inner_radius, -1);

    mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_stoke_width,
            (int) (STROKE_WIDTH_LARGE * density));
    mArrowWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_width, -1);
    mArrowHeight = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_height, -1);
    mTextSize = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_text_size,
            (int) (DEFAULT_TEXT_SIZE * density));
    mTextColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_text_color, Color.BLACK);

    mShowArrow = a.getBoolean(R.styleable.CircleProgressBar_mlpb_show_arrow, false);
    mCircleBackgroundEnabled = a.getBoolean(R.styleable.CircleProgressBar_mlpb_enable_circle_background, true);

    mProgress = a.getInt(R.styleable.CircleProgressBar_mlpb_progress, 0);
    mMax = a.getInt(R.styleable.CircleProgressBar_mlpb_max, 100);
    int textVisible = a.getInt(R.styleable.CircleProgressBar_mlpb_progress_text_visibility, 1);
    if (textVisible != 1) {
        mIfDrawText = true;//  w w w  .ja  va 2  s .  c o m
    }

    mTextPaint = new Paint();
    mTextPaint.setStyle(Paint.Style.FILL);
    mTextPaint.setColor(mTextColor);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setAntiAlias(true);
    a.recycle();
    mProgressDrawable = new MaterialProgressDrawable(getContext(), this);
    mProgressDrawable.setStartEndTrim(0, (float) 0.75);
    super.setImageDrawable(mProgressDrawable);
}

From source file:com.github.hilo.widget.MaterialCircleProgressBar.java

private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MaterialCircleProgressBar,
            defStyleAttr, 0);//w  w  w .j  ava2s  .  c o m

    final float density = getContext().getResources().getDisplayMetrics().density;

    mCircleBackGroundColor = a.getColor(R.styleable.MaterialCircleProgressBar_circle_background_color,
            DEFAULT_CIRCLE_BG_LIGHT);
    mCircleBackgroundEnabled = a.getBoolean(R.styleable.MaterialCircleProgressBar_enable_circle_background,
            true);
    mArrowColor = a.getColor(R.styleable.MaterialCircleProgressBar_arrow_color, DEFAULT_CIRCLE_BG_LIGHT);
    mColors = new int[] { mArrowColor };
    mArrowStokeWidth = a.getDimensionPixelOffset(
            R.styleable.MaterialCircleProgressBar_circle_progress_stoke_width,
            (int) (STROKE_WIDTH_LARGE * density));

    mShowArrow = a.getBoolean(R.styleable.MaterialCircleProgressBar_show_arrow, false);

    // if there are not set will have default values in onLayout method
    mInnerRadius = a.getDimensionPixelOffset(R.styleable.MaterialCircleProgressBar_circle_inner_radius, -1);
    mArrowWidth = a.getDimensionPixelOffset(R.styleable.MaterialCircleProgressBar_arrow_width, -1);
    mArrowHeight = a.getDimensionPixelOffset(R.styleable.MaterialCircleProgressBar_arrow_height, -1);

    a.recycle();
    mProgressDrawable = new MaterialArrowProgressDrawable(getContext(), this);
    mProgressDrawable.setStartEndTrim(0, (float) 0.75);
    super.setImageDrawable(mProgressDrawable);
}

From source file:com.youhei.easytools.view.progressbar.CircleProgressBar.java

private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar,
            defStyleAttr, 0);/*from   www  . ja  v a 2s .  com*/
    final float density = getContext().getResources().getDisplayMetrics().density;

    mBackGroundColor = typedArray.getColor(R.styleable.CircleProgressBar_mlpb_background_color,
            DEFAULT_CIRCLE_BG_LIGHT);

    mProgressColor = typedArray.getColor(R.styleable.CircleProgressBar_mlpb_progress_color,
            DEFAULT_CIRCLE_BG_LIGHT);
    mColors = new int[] { mProgressColor };

    mInnerRadius = typedArray.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_inner_radius, -1);

    mProgressStokeWidth = typedArray.getDimensionPixelOffset(
            R.styleable.CircleProgressBar_mlpb_progress_stoke_width, (int) (STROKE_WIDTH_LARGE * density));
    mArrowWidth = typedArray.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_width, -1);
    mArrowHeight = typedArray.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_height, -1);
    mTextSize = typedArray.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_text_size,
            (int) (DEFAULT_TEXT_SIZE * density));
    mTextColor = typedArray.getColor(R.styleable.CircleProgressBar_mlpb_progress_text_color, Color.BLACK);
    mShowArrow = typedArray.getBoolean(R.styleable.CircleProgressBar_mlpb_show_arrow, false);
    mCircleBackgroundEnabled = typedArray
            .getBoolean(R.styleable.CircleProgressBar_mlpb_enable_circle_background, true);

    mProgress = typedArray.getInt(R.styleable.CircleProgressBar_mlpb_progress, 0);
    mMax = typedArray.getInt(R.styleable.CircleProgressBar_mlpb_max, 100);
    int textVisible = typedArray.getInt(R.styleable.CircleProgressBar_mlpb_progress_text_visibility, 1);
    if (textVisible != 1) {
        mIfDrawText = true;
    }

    mTextPaint = new Paint();
    mTextPaint.setStyle(Paint.Style.FILL);
    mTextPaint.setColor(mTextColor);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setAntiAlias(true);
    typedArray.recycle();
    mProgressDrawable = new MaterialProgressDrawable(getContext(), this);
    super.setImageDrawable(mProgressDrawable);
}

From source file:com.magicwindow.deeplink.ui.CircleProgressBar.java

private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    final TypedArray a = context.obtainStyledAttributes(attrs,
            com.magicwindow.deeplink.R.styleable.CircleProgressBar, defStyleAttr, 0);
    final float density = getContext().getResources().getDisplayMetrics().density;

    mBackGroundColor = a.getColor(com.magicwindow.deeplink.R.styleable.CircleProgressBar_mlpb_background_color,
            DEFAULT_CIRCLE_BG_LIGHT);/*  www  .ja va 2s  .  com*/

    mProgressColor = a.getColor(com.magicwindow.deeplink.R.styleable.CircleProgressBar_mlpb_progress_color,
            DEFAULT_CIRCLE_BG_LIGHT);//ToDO 

    mInnerRadius = a.getDimensionPixelOffset(
            com.magicwindow.deeplink.R.styleable.CircleProgressBar_mlpb_inner_radius, -1);

    mProgressStokeWidth = a.getDimensionPixelOffset(
            com.magicwindow.deeplink.R.styleable.CircleProgressBar_mlpb_progress_stoke_width,
            (int) (STROKE_WIDTH_LARGE * density));
    mArrowWidth = a.getDimensionPixelOffset(
            com.magicwindow.deeplink.R.styleable.CircleProgressBar_mlpb_arrow_width, -1);
    mArrowHeight = a.getDimensionPixelOffset(
            com.magicwindow.deeplink.R.styleable.CircleProgressBar_mlpb_arrow_height, -1);
    mTextSize = a.getDimensionPixelOffset(
            com.magicwindow.deeplink.R.styleable.CircleProgressBar_mlpb_progress_text_size,
            (int) (DEFAULT_TEXT_SIZE * density));
    mTextColor = a.getColor(com.magicwindow.deeplink.R.styleable.CircleProgressBar_mlpb_progress_text_color,
            Color.BLACK);

    mShowArrow = a.getBoolean(com.magicwindow.deeplink.R.styleable.CircleProgressBar_mlpb_show_arrow, false);
    mCircleBackgroundEnabled = a.getBoolean(
            com.magicwindow.deeplink.R.styleable.CircleProgressBar_mlpb_enable_circle_background, true);

    mProgress = a.getInt(com.magicwindow.deeplink.R.styleable.CircleProgressBar_mlpb_progress, 0);
    mMax = a.getInt(com.magicwindow.deeplink.R.styleable.CircleProgressBar_mlpb_max, 100);
    int textVisible = a
            .getInt(com.magicwindow.deeplink.R.styleable.CircleProgressBar_mlpb_progress_text_visibility, 1);
    if (textVisible != 1) {
        mIfDrawText = true;
    }

    mTextPaint = new Paint();
    mTextPaint.setStyle(Paint.Style.FILL);
    mTextPaint.setColor(mTextColor);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setAntiAlias(true);
    a.recycle();
    mProgressDrawable = new MaterialProgressDrawable(getContext(), this);
    super.setImageDrawable(mProgressDrawable);
}

From source file:silent.kuasapmaterial.libs.MaterialProgressBar.java

private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MaterialProgressBar, defStyleAttr,
            0);/*  ww  w.j  a  va2  s.  com*/

    final float density = getContext().getResources().getDisplayMetrics().density;

    mBackGroundColor = a.getColor(R.styleable.MaterialProgressBar_background_color, DEFAULT_CIRCLE_BG_LIGHT);

    mProgressColor = a.getColor(R.styleable.MaterialProgressBar_progress_color, DEFAULT_CIRCLE_BG_LIGHT);

    mColors = new int[] { ContextCompat.getColor(getContext(), R.color.progress_red),
            ContextCompat.getColor(getContext(), R.color.progress_blue),
            ContextCompat.getColor(getContext(), R.color.progress_yellow),
            ContextCompat.getColor(getContext(), R.color.progress_green) };

    mInnerRadius = a.getDimensionPixelOffset(R.styleable.MaterialProgressBar_inner_radius, -1);

    mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.MaterialProgressBar_progress_stoke_width,
            (int) (STROKE_WIDTH_LARGE * density));
    mArrowWidth = a.getDimensionPixelOffset(R.styleable.MaterialProgressBar_arrow_width, -1);
    mArrowHeight = a.getDimensionPixelOffset(R.styleable.MaterialProgressBar_arrow_height, -1);
    mTextSize = a.getDimensionPixelOffset(R.styleable.MaterialProgressBar_progress_text_size,
            (int) (DEFAULT_TEXT_SIZE * density));
    mTextColor = a.getColor(R.styleable.MaterialProgressBar_progress_text_color, Color.BLACK);

    mShowArrow = a.getBoolean(R.styleable.MaterialProgressBar_show_arrow, false);
    mCircleBackgroundEnabled = a.getBoolean(R.styleable.MaterialProgressBar_enable_circle_background, true);

    mOverallSize = a.getInt(R.styleable.MaterialProgressBar_progress_overall_size, 2);

    mProgress = a.getInt(R.styleable.MaterialProgressBar_progress, 0);
    mMax = a.getInt(R.styleable.MaterialProgressBar_max, 100);
    int textVisible = a.getInt(R.styleable.MaterialProgressBar_progress_text_visibility, 1);
    if (textVisible != 1) {
        mIfDrawText = true;
    }

    mTextPaint = new Paint();
    mTextPaint.setStyle(Paint.Style.FILL);
    mTextPaint.setColor(mTextColor);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setAntiAlias(true);
    a.recycle();
    mProgressDrawable = new MaterialProgressDrawable(getContext(), this);
    super.setImageDrawable(mProgressDrawable);
}

From source file:com.actionbarsherlock.internal.widget.IcsSpinner.java

/**
 * Construct a new spinner with the given context's theme, the supplied attribute set,
 * and default style./*w w  w  .  j ava  2 s . co  m*/
 *
 * @param context The Context the view is running in, through which it can
 *        access the current theme, resources, etc.
 * @param attrs The attributes of the XML tag that is inflating the view.
 * @param defStyle The default style to apply to this view. If 0, no style
 *        will be applied (beyond what is included in the theme). This may
 *        either be an attribute resource, whose value will be retrieved
 *        from the current theme, or an explicit style resource.
 */
public IcsSpinner(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockSpinner, defStyle, 0);

    DropdownPopup popup = new DropdownPopup(context, attrs, defStyle);

    mDropDownWidth = a.getLayoutDimension(R.styleable.SherlockSpinner_android_dropDownWidth,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    popup.setBackgroundDrawable(a.getDrawable(R.styleable.SherlockSpinner_android_popupBackground));
    final int verticalOffset = a
            .getDimensionPixelOffset(R.styleable.SherlockSpinner_android_dropDownVerticalOffset, 0);
    if (verticalOffset != 0) {
        popup.setVerticalOffset(verticalOffset);
    }

    final int horizontalOffset = a
            .getDimensionPixelOffset(R.styleable.SherlockSpinner_android_dropDownHorizontalOffset, 0);
    if (horizontalOffset != 0) {
        popup.setHorizontalOffset(horizontalOffset);
    }

    mPopup = popup;

    mGravity = a.getInt(R.styleable.SherlockSpinner_android_gravity, Gravity.CENTER);

    mPopup.setPromptText(a.getString(R.styleable.SherlockSpinner_android_prompt));

    mDisableChildrenWhenDisabled = true;

    a.recycle();

    // Base constructor can call setAdapter before we initialize mPopup.
    // Finish setting things up if this happened.
    if (mTempAdapter != null) {
        mPopup.setAdapter(mTempAdapter);
        mTempAdapter = null;
    }
}

From source file:com.fuzz.indicator.CutoutViewIndicator.java

@SuppressWarnings("ResourceType")
protected void init(Context context, AttributeSet attrs, int defStyleAttr) {
    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CutoutViewIndicator);
        setIndicatorDrawableId(a.getResourceId(R.styleable.CutoutViewIndicator_rcv_drawable, 0));
        setInternalSpacing(a.getDimensionPixelOffset(R.styleable.CutoutViewIndicator_rcv_internal_margin, 0));

        // The superclass will have resolved orientation by now.
        if (getOrientation() == HORIZONTAL) {
            setPerpendicularLength(//from w w  w  .  j ava  2 s  . com
                    a.getDimensionPixelSize(R.styleable.CutoutViewIndicator_rcv_height, WRAP_CONTENT));
            setCellLength(a.getDimensionPixelOffset(R.styleable.CutoutViewIndicator_rcv_width, WRAP_CONTENT));
        } else {
            setPerpendicularLength(
                    a.getDimensionPixelSize(R.styleable.CutoutViewIndicator_rcv_width, WRAP_CONTENT));
            setCellLength(a.getDimensionPixelOffset(R.styleable.CutoutViewIndicator_rcv_height, WRAP_CONTENT));
        }

        if (isInEditMode()) {
            editModePageCount = a.getInteger(R.styleable.CutoutViewIndicator_rcv_tools_indicator_count, 2);
        }

        String generatorName = a.getString(R.styleable.CutoutViewIndicator_rcv_generator_class_name);
        if (generatorName != null) {
            CCGFactory.constructGeneratorFrom(context, attrs, defStyleAttr, generatorName,
                    new ConstructorCallback() {
                        @Override
                        public void onGenerated(@NonNull CutoutCellGenerator generated) {
                            CutoutViewIndicator.this.generator = generated;
                        }

                        @Override
                        public void onFailed(@NonNull String message) {
                            if (!message.isEmpty()) {
                                Log.e(TAG, message);
                                if (isInEditMode()) {
                                    String tag = "resources.invalid";
                                    logger.logToLayoutLib(tag, message);
                                }
                            }
                        }
                    });

        }

        setCellBackgroundId(a.getResourceId(R.styleable.CutoutViewIndicator_rcv_drawable_unselected, 0));
        a.recycle();
    }
    if (isInEditMode()) {
        setStateProxy(EDIT_MODE_PROXY);
    }
}

From source file:org.indonesiax.mobile.view.custom.popup.menu.MenuPopupHelper.java

public MenuPopupHelper(Context context, MenuBuilder menu, View anchorView, boolean overflowOnly,
        int popupStyleAttr, int popupStyleRes) {
    mContext = context;//from  w ww  .j a v  a  2 s. c  o  m
    mInflater = LayoutInflater.from(context);
    mMenu = menu;
    mAdapter = new MenuAdapter();
    mOverflowOnly = overflowOnly;
    mPopupStyleAttr = popupStyleAttr;
    mPopupStyleRes = popupStyleRes;

    final Resources res = context.getResources();
    mPopupMaxWidth = Math.max(res.getDisplayMetrics().widthPixels / 2,
            res.getDimensionPixelSize(android.support.v7.appcompat.R.dimen.abc_config_prefDialogWidth));

    TypedArray a = context.obtainStyledAttributes(null, R.styleable.PopupMenu, mPopupStyleAttr, mPopupStyleRes);
    mPopupMinWidth = a.getDimensionPixelSize(R.styleable.PopupMenu_android_minWidth, 0);
    int popupPadding = a.getDimensionPixelSize(R.styleable.PopupMenu_android_padding, -1);
    if (popupPadding >= 0) {
        mPopupPaddingStart = popupPadding;
        mPopupPaddingEnd = popupPadding;
        mPopupPaddingTop = popupPadding;
        mPopupPaddingBottom = popupPadding;
    } else {
        mPopupPaddingStart = a.getDimensionPixelSize(R.styleable.PopupMenu_android_paddingStart,
                a.getDimensionPixelOffset(R.styleable.PopupMenu_android_paddingLeft, 0));
        mPopupPaddingEnd = a.getDimensionPixelSize(R.styleable.PopupMenu_android_paddingEnd,
                a.getDimensionPixelOffset(R.styleable.PopupMenu_android_paddingRight, 0));
        mPopupPaddingTop = a.getDimensionPixelSize(R.styleable.PopupMenu_android_paddingTop, 0);
        mPopupPaddingBottom = a.getDimensionPixelSize(R.styleable.PopupMenu_android_paddingBottom, 0);
    }
    mPopupItemVerticalPadding = a.getDimensionPixelSize(R.styleable.PopupMenu_itemVerticalPadding, 0);
    mPopupIconPadding = a.getDimensionPixelSize(R.styleable.PopupMenu_iconPadding, 0);
    mPopupIconDefaultSize = a.getDimensionPixelSize(R.styleable.PopupMenu_iconDefaultSize, 0);
    mPopupHeaderTextAppearance = a.getResourceId(R.styleable.PopupMenu_headerTextAppearance, -1);
    mPopupRowTextAppearance = a.getResourceId(R.styleable.PopupMenu_rowTextAppearance, -1);
    a.recycle();

    mAnchorView = anchorView;

    // Present the menu using our context, not the menu builder's context.
    menu.addMenuPresenter(this, context);
}