Example usage for android.content.res TypedArray getDimensionPixelSize

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

Introduction

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

Prototype

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

Source Link

Document

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

Usage

From source file:ch.heigvd.wordhunt.Interaction.FloatLabelLayout.java

public void init(Context context, AttributeSet attrs) {

    setOrientation(VERTICAL);/* www . j a  va2  s . c  o m*/

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatLabelLayout);

    int leftPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingLeft,
            dipsToPix(DEFAULT_LABEL_PADDING_LEFT));
    int topPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingTop,
            dipsToPix(DEFAULT_LABEL_PADDING_TOP));
    int rightPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingRight,
            dipsToPix(DEFAULT_LABEL_PADDING_RIGHT));
    int bottomPadding = a.getDimensionPixelSize(R.styleable.FloatLabelLayout_floatLabelPaddingBottom,
            dipsToPix(DEFAULT_LABEL_PADDING_BOTTOM));
    mHint = a.getText(R.styleable.FloatLabelLayout_floatLabelHint);

    mLabel = new TextView(context);
    mLabel.setPadding(leftPadding, topPadding, rightPadding, bottomPadding);
    mLabel.setVisibility(INVISIBLE);
    mLabel.setText(mHint);
    ViewCompat.setPivotX(mLabel, 0f);
    ViewCompat.setPivotY(mLabel, 0f);

    mLabel.setTextAppearance(context, a.getResourceId(R.styleable.FloatLabelLayout_floatLabelTextAppearance,
            android.R.style.TextAppearance_Small));
    a.recycle();

    addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    mInterpolator = AnimationUtils.loadInterpolator(context,
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? android.R.interpolator.fast_out_slow_in
                    : android.R.anim.decelerate_interpolator);
}

From source file:com.mobileglobe.android.customdialer.common.list.ViewPagerTabs.java

public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);/*from   w  w w . ja  v  a 2 s . c  o m*/

    mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    mTextAllCaps = a.getBoolean(3, false);

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    a.recycle();

    if (CompatUtils.isLollipopCompatible()) {
        // enable shadow casting from view bounds
        setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER);
    }
}

From source file:com.android.contacts.common.list.ViewPagerTabs.java

public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);//w w w  .j a  v a  2 s  .  c  o m

    mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS);

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mTextSize = a.getDimensionPixelSize(0, 0);
    mTextStyle = a.getInt(1, 0);
    mTextColor = a.getColorStateList(2);
    mTextAllCaps = a.getBoolean(3, false);

    mTabStrip = new ViewPagerTabStrip(context);
    addView(mTabStrip, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    a.recycle();

    if (CompatUtils.isLollipopCompatible()) {
        // enable shadow casting from view bounds
        setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER);
    }
}

From source file:com.pedrovgs.draggablepanel.DraggablePanel.java

/**
 * Initialize the xml configuration based on styleable attributes
 *
 * @param attrs to analyze./*from w ww . ja v  a2 s  . c om*/
 */
private void initializeAttrs(AttributeSet attrs) {
    TypedArray attributes = getContext().obtainStyledAttributes(attrs, R.styleable.draggable_panel);
    this.topFragmentHeight = attributes.getDimensionPixelSize(R.styleable.draggable_panel_top_fragment_height,
            DEFAULT_TOP_FRAGMENT_HEIGHT);
    this.xScaleFactor = attributes.getFloat(R.styleable.draggable_panel_x_scale_factor, DEFAULT_SCALE_FACTOR);
    this.yScaleFactor = attributes.getFloat(R.styleable.draggable_panel_y_scale_factor, DEFAULT_SCALE_FACTOR);
    this.topFragmentMarginRight = attributes.getDimensionPixelSize(
            R.styleable.draggable_panel_top_fragment_margin_right, DEFAULT_TOP_FRAGMENT_MARGIN);
    this.topFragmentMarginBottom = attributes.getDimensionPixelSize(
            R.styleable.draggable_panel_top_fragment_margin_bottom, DEFAULT_TOP_FRAGMENT_MARGIN);
    this.enableHorizontalAlphaEffect = attributes.getBoolean(
            R.styleable.draggable_panel_enable_horizontal_alpha_effect, DEFAULT_ENABLE_HORIZONTAL_ALPHA_EFFECT);
    attributes.recycle();
}

From source file:com.astuetz.viewpager.extensions.FixedTabsView.java

public FixedTabsView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);

    this.mContext = context;

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

    mDividerColor = a.getColor(R.styleable.ViewPagerExtensions_dividerColor, mDividerColor);

    mDividerMarginTop = a.getDimensionPixelSize(R.styleable.ViewPagerExtensions_dividerMarginTop,
            mDividerMarginTop);//from ww w  .j  av  a 2 s .co  m
    mDividerMarginBottom = a.getDimensionPixelSize(R.styleable.ViewPagerExtensions_dividerMarginBottom,
            mDividerMarginBottom);

    mDividerDrawable = a.getDrawable(R.styleable.ViewPagerExtensions_dividerDrawable);

    a.recycle();

    this.setOrientation(LinearLayout.HORIZONTAL);
}

From source file:com.actionbarsherlock.internal.view.menu.ActionMenuItemView.java

public ActionMenuItemView(Context context, AttributeSet attrs, int defStyle) {
    //TODO super(context, attrs, defStyle);
    super(context, attrs);
    mAllowTextWithIcon = getResources_getBoolean(context, R.bool.abs__config_allowActionMenuItemTextWithIcon);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionMenuItemView, 0, 0);
    mMinWidth = a.getDimensionPixelSize(R.styleable.SherlockActionMenuItemView_android_minWidth, 0);
    a.recycle();/*from w  ww .  j a va2s. c om*/
}

From source file:com.lithiumli.fiction.FictionActivity.java

protected void setQueueMargin() {
    TypedValue typedValue = new TypedValue();
    getTheme().resolveAttribute(android.R.attr.actionBarSize, typedValue, true);
    int[] attr = new int[] { android.R.attr.actionBarSize };
    TypedArray a = obtainStyledAttributes(typedValue.data, attr);
    int abHeight = a.getDimensionPixelSize(0, -1);
    a.recycle();/*from  w w  w. j a va  2  s  .  c o  m*/

    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mQueueListView.getLayoutParams();
    params.setMargins(0, abHeight, 0, 0);
    mQueueListView.setLayoutParams(params);
}

From source file:com.dlazaro66.wheelindicatorview.WheelIndicatorView.java

private void init(AttributeSet attrs) {
    TypedArray attributesArray = getContext().getTheme().obtainStyledAttributes(attrs,
            R.styleable.WheelIndicatorView, 0, 0);

    int itemsLineWidth = attributesArray.getDimensionPixelSize(R.styleable.WheelIndicatorView_itemsLineWidth,
            DEFAULT_ITEM_LINE_WIDTH);/*w  w w . j a v  a  2s  . co m*/
    setItemsLineWidth(itemsLineWidth);

    int filledPercent = attributesArray.getInt(R.styleable.WheelIndicatorView_filledPercent,
            DEFAULT_FILLED_PERCENT);
    setFilledPercent(filledPercent);

    int bgColor = attributesArray.getColor(R.styleable.WheelIndicatorView_backgroundColor, -1);
    if (bgColor != -1)
        setBackgroundColor(bgColor);

    this.wheelIndicatorItems = new ArrayList<>();
    this.wheelItemsAngles = new ArrayList<>();

    itemArcPaint = new Paint();
    itemArcPaint.setStyle(Paint.Style.STROKE);
    itemArcPaint.setStrokeWidth(itemsLineWidth * 2);
    itemArcPaint.setAntiAlias(true);

    innerBackgroundCirclePaint = new Paint();
    innerBackgroundCirclePaint.setColor(INNER_BACKGROUND_CIRCLE_COLOR);
    innerBackgroundCirclePaint.setStyle(Paint.Style.STROKE);
    innerBackgroundCirclePaint.setStrokeWidth(itemsLineWidth * 2);
    innerBackgroundCirclePaint.setAntiAlias(true);

    itemEndPointsPaint = new Paint();
    itemEndPointsPaint.setAntiAlias(true);
}

From source file:com.laynemobile.android.widget.AndroidDrawer.java

private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NavigationView, defStyleAttr,
            R.style.Widget_Design_NavigationView);
    Util.setViewBackground(this, a.getDrawable(R.styleable.NavigationView_android_background));
    if (a.hasValue(R.styleable.NavigationView_elevation)) {
        ViewCompat.setElevation(this, (float) a.getDimensionPixelSize(R.styleable.NavigationView_elevation, 0));
    }//from w  w  w. j a  va2  s. co m
    ViewCompat.setFitsSystemWindows(this,
            a.getBoolean(R.styleable.NavigationView_android_fitsSystemWindows, false));
    this.maxWidth = a.getDimensionPixelSize(R.styleable.NavigationView_android_maxWidth, 0);
    this.widthMargin = Util.getActionBarSize(context);
    a.recycle();
}

From source file:com.lightplus.MainActivity.java

/**
 * Calculate height of actionbar./*w w w  .java 2  s  . c o m*/
 */
private void calcActionBarHeight() {
    int[] abSzAttr;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        abSzAttr = new int[] { android.R.attr.actionBarSize };
    } else {
        abSzAttr = new int[] { R.attr.actionBarSize };
    }
    TypedArray a = obtainStyledAttributes(abSzAttr);
    mActionBarHeight = a.getDimensionPixelSize(0, -1);
}