List of usage examples for android.content.res TypedArray getDimension
public float getDimension(@StyleableRes int index, float defValue)
From source file:am.widget.MaterialProgressImageView.java
private void initView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { final float density = getResources().getDisplayMetrics().density; ArrayList<Integer> colors = new ArrayList<>(); TypedArray custom = context.obtainStyledAttributes(attrs, R.styleable.MaterialProgressImageView, defStyleAttr, defStyleRes);//from w ww . ja v a 2 s .co m boolean autoStart = custom.getBoolean(R.styleable.MaterialProgressImageView_mpiAutoStart, true); int color = custom.getColor(R.styleable.MaterialProgressImageView_mpiShadowsCircleColor, DEFAULT_COLOR); float elevation = custom.getDimension(R.styleable.MaterialProgressImageView_mpiElevation, density * SHADOW_ELEVATION); if (custom.hasValue(R.styleable.MaterialProgressImageView_mpiSchemeColor1)) { colors.add(custom.getColor(R.styleable.MaterialProgressImageView_mpiSchemeColor1, Color.BLACK)); } if (custom.hasValue(R.styleable.MaterialProgressImageView_mpiSchemeColor2)) { colors.add(custom.getColor(R.styleable.MaterialProgressImageView_mpiSchemeColor2, Color.BLACK)); } if (custom.hasValue(R.styleable.MaterialProgressImageView_mpiSchemeColor3)) { colors.add(custom.getColor(R.styleable.MaterialProgressImageView_mpiSchemeColor3, Color.BLACK)); } if (custom.hasValue(R.styleable.MaterialProgressImageView_mpiSchemeColor4)) { colors.add(custom.getColor(R.styleable.MaterialProgressImageView_mpiSchemeColor4, Color.BLACK)); } if (custom.hasValue(R.styleable.MaterialProgressImageView_mpiSchemeColor5)) { colors.add(custom.getColor(R.styleable.MaterialProgressImageView_mpiSchemeColor5, Color.BLACK)); } custom.recycle(); setElevationCompat(elevation); Drawable background = getBackground(); if (background == null) setShadowsCircleBackground(color); drawable = new MaterialProgressDrawable(density); drawable.setBackgroundColor(0x00000000); drawable.setAlpha(255); drawable.setCallback(this); final int size = colors.size(); if (size > 0) { int[] colorArray = new int[size]; for (int i = 0; i < size; i++) { colorArray[i] = colors.get(i); } drawable.setColorSchemeColors(colorArray); } setImageDrawable(drawable); if (autoStart) start(); }
From source file:android_hddl_framework.viewpagerindicator.LinePageIndicator.java
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//from www. j av a 2 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.irccloud.android.DrawerArrowDrawable.java
/** * @param context used to get the configuration for the drawable from *///from ww w.ja va 2 s.co m public DrawerArrowDrawable(Activity context) { final TypedArray typedArray = context.getTheme().obtainStyledAttributes(null, R.styleable.DrawerArrowToggle, R.attr.drawerArrowStyle, R.style.Base_Widget_AppCompat_DrawerArrowToggle); mContext = context; mPaint.setAntiAlias(true); mPaint.setColor(typedArray.getColor(R.styleable.DrawerArrowToggle_color, 0)); mSize = typedArray.getDimensionPixelSize(R.styleable.DrawerArrowToggle_drawableSize, 0); mBarSize = typedArray.getDimension(R.styleable.DrawerArrowToggle_barSize, 0); mTopBottomArrowSize = typedArray.getDimension(R.styleable.DrawerArrowToggle_topBottomBarArrowSize, 0); mBarThickness = typedArray.getDimension(R.styleable.DrawerArrowToggle_thickness, 0); mBarGap = typedArray.getDimension(R.styleable.DrawerArrowToggle_gapBetweenBars, 0); mSpin = typedArray.getBoolean(R.styleable.DrawerArrowToggle_spinBars, true); mMiddleArrowSize = typedArray.getDimension(R.styleable.DrawerArrowToggle_middleBarArrowSize, 0); typedArray.recycle(); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.SQUARE); mPaint.setStrokeWidth(mBarThickness); }
From source file:com.cmbb.smartkids.photopicker.widget.indication.LinePageIndicator.java
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//from ww w . ja va 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); }
From source file:com.jaspersoft.android.jaspermobile.activities.profile.ServerProfileActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final TypedArray styledAttributes = getTheme() .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize }); mActionBarSize = (int) styledAttributes.getDimension(0, 0); styledAttributes.recycle();/*ww w .j av a 2 s .co m*/ ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } invalidateOptionsMenu(); if (profileId != 0 && savedInstanceState == null) { getSupportLoaderManager().initLoader(LOAD_PROFILE, null, this); } }
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;// w w w. ja va 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.app.laundry.tabs.lib.LinePageIndicator2.java
public LinePageIndicator2(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//ww w. j ava 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.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.caro.smartmodule.viewComponent.viewpagerindicator.LinePageIndicator.java
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;// w ww. ja v a 2 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.LinePageIndicator, defStyle, 0); mCentered = a.getBoolean(R.styleable.LinePageIndicator_vpicentered, 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.lee.sdk.widget.viewpager.DrawablePageIndicator.java
@SuppressWarnings("deprecation") public DrawablePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*w w w .ja v a 2 s .c o m*/ //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DrawablePageIndicator, defStyle, 0); Drawable background = a.getDrawable(R.styleable.DrawablePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } mShadowLeft = a.getDimension(R.styleable.DrawablePageIndicator_shadow_left, 0.0f); mShadowRight = a.getDimension(R.styleable.DrawablePageIndicator_shadow_right, 0.0f); mDrawable = a.getDrawable(R.styleable.DrawablePageIndicator_android_src); if (mDrawable == null) { mDrawable = new ColorDrawable(Color.WHITE); } 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;/*from www .j a v a 2 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); }