Example usage for android.content.res Resources getDimension

List of usage examples for android.content.res Resources getDimension

Introduction

In this page you can find the example usage for android.content.res Resources getDimension.

Prototype

public float getDimension(@DimenRes int id) throws NotFoundException 

Source Link

Document

Retrieve a dimensional for a particular resource ID.

Usage

From source file:com.app.laundry.tabs.lib.LinePageIndicator2.java

public LinePageIndicator2(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from w  ww .  ja  va2 s  .c  om*/

    final Resources res = getResources();

    //Load defaults from resources
    final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
    final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
    final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
    final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
    final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator2, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.LinePageIndicator2_centered, defaultCentered);
    mLineWidth = a.getDimension(R.styleable.LinePageIndicator2_lineWidth, defaultLineWidth);
    mGapWidth = a.getDimension(R.styleable.LinePageIndicator2_gapWidth, defaultGapWidth);
    setStrokeWidth(a.getDimension(R.styleable.LinePageIndicator2_strokeWidth, defaultStrokeWidth));
    mPaintUnselected
            .setColor(a.getColor(R.styleable.LinePageIndicator2_unselectedColor, defaultUnselectedColor));
    mPaintSelected.setColor(a.getColor(R.styleable.LinePageIndicator2_selectedColor, defaultSelectedColor));

    Drawable background = a.getDrawable(R.styleable.LinePageIndicator2_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.velocityviewpagerindicator.VelocityLinePageIndicator.java

public VelocityLinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from  w  w  w  . ja va2s .  co m*/

    final Resources res = getResources();

    //Load defaults from resources
    final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
    final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
    final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
    final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
    final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.VelocityLinePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.VelocityLinePageIndicator_centered, defaultCentered);
    mLineWidth = a.getDimension(R.styleable.VelocityLinePageIndicator_lineWidth, defaultLineWidth);
    mGapWidth = a.getDimension(R.styleable.VelocityLinePageIndicator_gapWidth, defaultGapWidth);
    setStrokeWidth(a.getDimension(R.styleable.VelocityLinePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintUnselected.setColor(
            a.getColor(R.styleable.VelocityLinePageIndicator_unselectedColor, defaultUnselectedColor));
    mPaintSelected
            .setColor(a.getColor(R.styleable.VelocityLinePageIndicator_selectedColor, defaultSelectedColor));

    Drawable background = a.getDrawable(R.styleable.VelocityLinePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.along.altmcssd.pda.widget.viewpagerindicator.LinePageIndicator.java

public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;//from w  w  w . jav a  2s. c  om

    final Resources res = getResources();

    // Load defaults from resources
    final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
    final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
    final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
    final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
    final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);

    // Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, defaultCentered);
    mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth);
    mGapWidth = a.getDimension(R.styleable.LinePageIndicator_gapWidth, defaultGapWidth);
    setStrokeWidth(a.getDimension(R.styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintUnselected
            .setColor(a.getColor(R.styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor));
    mPaintSelected.setColor(a.getColor(R.styleable.LinePageIndicator_selectedColor, defaultSelectedColor));

    Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.ateam.shippingcity.widget.viewpagerindicator.LinePageIndicator.java

@SuppressWarnings("deprecation")
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/* w w  w .  j  av  a  2 s . com*/

    final Resources res = getResources();

    //Load defaults from resources
    final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
    final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
    final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
    final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
    final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, defaultCentered);
    mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth);
    mGapWidth = a.getDimension(R.styleable.LinePageIndicator_gapWidth, defaultGapWidth);
    setStrokeWidth(a.getDimension(R.styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintUnselected
            .setColor(a.getColor(R.styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor));
    mPaintSelected.setColor(a.getColor(R.styleable.LinePageIndicator_selectedColor, defaultSelectedColor));

    Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.sflib.CustomView.indicator.LinePageIndicator.java

public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from   ww w.j  a  v  a2 s  .  c  o m*/

    final Resources res = getResources();

    //Load defaults from resources
    final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
    final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
    final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
    final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
    final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, defaultCentered);
    mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth);
    //TODO do it
    //        mGapWidth = a.getDimension(com.sflib.CustomView.R.styleable.LinePageIndicator_gapWidth, defaultGapWidth);
    mGapWidth = defaultGapWidth;
    setStrokeWidth(a.getDimension(R.styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintUnselected
            .setColor(a.getColor(R.styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor));
    mPaintSelected.setColor(a.getColor(R.styleable.LinePageIndicator_selectedColor, defaultSelectedColor));

    Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.mozhuowen.widget.autoscrollviewpager.indicator.LinePageIndicator.java

public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from ww w .j  av  a2 s.c o  m*/

    final Resources res = getResources();

    //Load defaults from resources
    final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
    final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
    final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
    final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
    final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator, defStyle, 0);

    //        mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, defaultCentered);
    //        mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth);
    //        mGapWidth = a.getDimension(R.styleable.LinePageIndicator_gapWidth, defaultGapWidth);
    mCentered = defaultCentered;
    mLineWidth = defaultLineWidth;
    mGapWidth = defaultGapWidth;
    setStrokeWidth(a.getDimension(R.styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintUnselected
            .setColor(a.getColor(R.styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor));
    mPaintSelected.setColor(a.getColor(R.styleable.LinePageIndicator_selectedColor, defaultSelectedColor));

    Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.tct.mail.browse.SubjectAndFolderView.java

public SubjectAndFolderView(Context context, AttributeSet attrs) {
    super(context, attrs);

    //TS: yanhua.chen 2015-4-16 EMAIL BUGFIX_963186 ADD_S
    activity = (Activity) context;//from w  w w.  j  a v a 2 s  . co  m
    //TS: yanhua.chen 2015-4-16 EMAIL BUGFIX_963186 ADD_E
    mVisibleFolders = false;
    mFolderDisplayer = new ConversationFolderDisplayer(getContext(), this);

    final Resources r = getResources();
    mFolderPadding = r.getDimensionPixelOffset(R.dimen.conversation_folder_padding);
    mFolderPaddingExtraWidth = r.getDimensionPixelOffset(R.dimen.conversation_folder_padding_extra_width);
    mFolderPaddingAfter = r.getDimensionPixelOffset(R.dimen.conversation_folder_padding_after);
    mRoundedCornerRadius = r.getDimensionPixelOffset(R.dimen.folder_rounded_corner_radius);
    mFolderSpanTextSize = r.getDimension(R.dimen.conversation_folder_font_size);
    mFolderMarginTop = r.getDimensionPixelOffset(R.dimen.conversation_folder_margin_top);
}

From source file:com.tsingning.view.TabPageIndicators.LinePageIndicator.java

@SuppressWarnings("deprecation")
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) {
        return;/*from www . j a va2 s . co m*/
    }

    final Resources res = getResources();

    //Load defaults from resources
    final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
    final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
    final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
    final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
    final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, defaultCentered);
    mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth);
    mGapWidth = a.getDimension(R.styleable.LinePageIndicator_gapWidth, defaultGapWidth);
    setStrokeWidth(a.getDimension(R.styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintUnselected
            .setColor(a.getColor(R.styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor));
    mPaintSelected.setColor(a.getColor(R.styleable.LinePageIndicator_selectedColor, defaultSelectedColor));

    Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}

From source file:com.dragon.lib.IndicatorView.java

private void init(AttributeSet attrs, int defStyle) {
    final Resources res = getResources();

    final int defaultIndicatorSelectedColor = res.getColor(R.color.indicator_selected);
    final int defaultIndicatorUnseletedColor = res.getColor(R.color.indicator_unselected);
    final float defaultWidth = res.getDimension(R.dimen.indicator_width);
    final float defaultIndicatorHeight = res.getDimension(R.dimen.indicator_line_height);
    final int defaultIndicatorBackground = res.getColor(R.color.indicator_backgroup);
    final int defaultPosition = CENTER;
    mIndicatorHeight = defaultIndicatorHeight;
    mIndicatorPaint.setStyle(Paint.Style.FILL);

    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ScrollImageView);

    mIndicatorSelectedColor = a.getColor(R.styleable.ScrollImageView_indicatorSelectedColor,
            defaultIndicatorSelectedColor);
    mIndicatorUnselectedColor = a.getColor(R.styleable.ScrollImageView_indicatorUnselectedColor,
            defaultIndicatorUnseletedColor);
    mIndicatorType = a.getInt(R.styleable.ScrollImageView_indicatorType, CIRCLE);
    mIndicatorBackground = a.getResourceId(R.styleable.ScrollImageView_indicatorBackground,
            defaultIndicatorBackground);
    mIndicatorPosition = a.getInt(R.styleable.ScrollImageView_indicatorPosition, defaultPosition);
    mIndicatorWidth = a.getDimension(R.styleable.ScrollImageView_indicatorWidth, defaultWidth);
    mIndicatorHeight = a.getDimension(R.styleable.ScrollImageView_indicatorHeight, defaultIndicatorHeight);

    a.recycle();//ww w.ja va2  s .c o  m

    mIndicatorPaint.setStrokeWidth(mIndicatorHeight);
}

From source file:com.viewpagerindicator.LoopingLinePageIndicator.java

public LoopingLinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode())
        return;/*from ww  w.j av a 2  s  .c  o  m*/

    final Resources res = getResources();

    //Load defaults from resources
    final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
    final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
    final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
    final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
    final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);

    //Retrieve styles attributes
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator, defStyle, 0);

    mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, defaultCentered);
    mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth);
    mGapWidth = a.getDimension(R.styleable.LinePageIndicator_gapWidth, defaultGapWidth);
    setStrokeWidth(a.getDimension(R.styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth));
    mPaintUnselected
            .setColor(a.getColor(R.styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor));
    mPaintSelected.setColor(a.getColor(R.styleable.LinePageIndicator_selectedColor, defaultSelectedColor));

    Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
    if (background != null) {
        setBackgroundDrawable(background);
    }

    a.recycle();

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}