List of usage examples for android.content.res TypedArray getDimension
public float getDimension(@StyleableRes int index, float defValue)
From source file:com.bolaa.medical.view.banner.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color); final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color); final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color); final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width); final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius); final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, R.style.Widget_CirclePageIndicator); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_orientation, defaultOrientation); mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintPageFill.setStyle(Style.STROKE); mPaintPageFill.setStrokeWidth(1);// mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke/*from w w w . j a va2s . c o m*/ .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintFill.setStyle(Style.FILL);// mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius); mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap); a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:android.support.design.widget.FloatingActionButton.java
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ThemeUtils.checkAppCompatTheme(context); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, R.style.Widget_Design_FloatingActionButton); mBackgroundTint = a.getColorStateList(R.styleable.FloatingActionButton_backgroundTint); mBackgroundTintMode = ViewUtils//from ww w . jav a2 s.co m .parseTintMode(a.getInt(R.styleable.FloatingActionButton_backgroundTintMode, -1), null); mRippleColor = a.getColor(R.styleable.FloatingActionButton_rippleColor, 0); mSize = a.getInt(R.styleable.FloatingActionButton_fabSize, SIZE_AUTO); mBorderWidth = a.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0); final float elevation = a.getDimension(R.styleable.FloatingActionButton_elevation, 0f); final float pressedTranslationZ = a.getDimension(R.styleable.FloatingActionButton_pressedTranslationZ, 0f); mCompatPadding = a.getBoolean(R.styleable.FloatingActionButton_useCompatPadding, false); a.recycle(); mImageHelper = new AppCompatImageHelper(this); mImageHelper.loadFromAttributes(attrs, defStyleAttr); mMaxImageSize = (int) getResources().getDimension(R.dimen.design_fab_image_size); getImpl().setBackgroundDrawable(mBackgroundTint, mBackgroundTintMode, mRippleColor, mBorderWidth); getImpl().setElevation(elevation); getImpl().setPressedTranslationZ(pressedTranslationZ); }
From source file:com.example.pierrechanson.prototypebottomsheet.BottomSheetBehaviorGoogleMapsLike.java
/** * Default constructor for inflating BottomSheetBehaviors from layout. * * @param context The {@link Context}.//from w w w . j ava 2 s.co m * @param attrs The {@link AttributeSet}. */ public BottomSheetBehaviorGoogleMapsLike(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, android.support.design.R.styleable.BottomSheetBehavior_Params); setPeekHeight(a.getDimensionPixelSize( android.support.design.R.styleable.BottomSheetBehavior_Params_behavior_peekHeight, 0)); setHideable(a.getBoolean(android.support.design.R.styleable.BottomSheetBehavior_Params_behavior_hideable, false)); a.recycle(); /** * Getting the anchorPoint... */ mAnchorPoint = DEFAULT_ANCHOR_POINT; a = context.obtainStyledAttributes(attrs, R.styleable.CustomBottomSheetBehavior); if (attrs != null) mAnchorPoint = (int) a.getDimension(R.styleable.CustomBottomSheetBehavior_anchorPoint, 0); a.recycle(); ViewConfiguration configuration = ViewConfiguration.get(context); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); }
From source file:com.bolaa.sleepingbar.view.banner.LoopCirclePageIndicator.java
public LoopCirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color); final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color); final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color); final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width); final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius); final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, R.style.Widget_CirclePageIndicator); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_orientation, defaultOrientation); mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setStrokeWidth(3);//? mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintStroke.setStyle(Style.FILL); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke//www. ja v a 2 s . c om .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintFill.setStyle(Style.FILL);// mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius); mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap); a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.android.incallui.widget.multiwaveview.GlowPadView.java
public GlowPadView(Context context, AttributeSet attrs) { super(context, attrs); Resources res = context.getResources(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GlowPadView); mInnerRadius = a.getDimension(R.styleable.GlowPadView_innerRadius, mInnerRadius); mOuterRadius = a.getDimension(R.styleable.GlowPadView_outerRadius, mOuterRadius); mSnapMargin = a.getDimension(R.styleable.GlowPadView_snapMargin, mSnapMargin); mVibrationDuration = a.getInt(R.styleable.GlowPadView_vibrationDuration, mVibrationDuration); mFeedbackCount = a.getInt(R.styleable.GlowPadView_feedbackCount, mFeedbackCount); mAllowScaling = a.getBoolean(R.styleable.GlowPadView_allowScaling, false); TypedValue handle = a.peekValue(R.styleable.GlowPadView_handleDrawable); setHandleDrawable(handle != null ? handle.resourceId : R.drawable.ic_incall_audio_handle); mOuterRing = new TargetDrawable(res, getResourceId(a, R.styleable.GlowPadView_outerRingDrawable), 1); mAlwaysTrackFinger = a.getBoolean(R.styleable.GlowPadView_alwaysTrackFinger, false); int pointId = getResourceId(a, R.styleable.GlowPadView_pointDrawable); Drawable pointDrawable = pointId != 0 ? res.getDrawable(pointId) : null; mGlowRadius = a.getDimension(R.styleable.GlowPadView_glowRadius, 0.0f); TypedValue outValue = new TypedValue(); // Read array of target drawables if (a.getValue(R.styleable.GlowPadView_targetDrawables, outValue)) { internalSetTargetResources(outValue.resourceId); }//from w w w . ja v a2s . c om if (mTargetDrawables == null || mTargetDrawables.size() == 0) { throw new IllegalStateException("Must specify at least one target drawable"); } // Read array of target descriptions if (a.getValue(R.styleable.GlowPadView_targetDescriptions, outValue)) { final int resourceId = outValue.resourceId; if (resourceId == 0) { throw new IllegalStateException("Must specify target descriptions"); } setTargetDescriptionsResourceId(resourceId); } // Read array of direction descriptions if (a.getValue(R.styleable.GlowPadView_directionDescriptions, outValue)) { final int resourceId = outValue.resourceId; if (resourceId == 0) { throw new IllegalStateException("Must specify direction descriptions"); } setDirectionDescriptionsResourceId(resourceId); } // Use gravity attribute from LinearLayout //a = context.obtainStyledAttributes(attrs, R.styleable.LinearLayout); mGravity = a.getInt(R.styleable.GlowPadView_android_gravity, Gravity.TOP); a.recycle(); setVibrateEnabled(mVibrationDuration > 0); assignDefaultsIfNeeded(); mPointCloud = new PointCloud(pointDrawable); mPointCloud.makePointCloud(mInnerRadius, mOuterRadius); mPointCloud.glowManager.setRadius(mGlowRadius); mExploreByTouchHelper = new GlowpadExploreByTouchHelper(this); ViewCompat.setAccessibilityDelegate(this, mExploreByTouchHelper); }
From source file:com.bolaa.medical.view.banner.LoopCirclePageIndicator.java
public LoopCirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color); final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color); final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color); final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width); final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius); final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, R.style.Widget_CirclePageIndicator); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_orientation, defaultOrientation); mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintPageFill.setStyle(Style.FILL); // mPaintPageFill.setStrokeWidth(3);//? mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintStroke.setStyle(Style.FILL); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke// w w w. j av a2s.com .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintFill.setStyle(Style.FILL);// mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius); mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap); a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.tandong.sa.vpic.TitlePageIndicator.java
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/* w ww . j av a 2 s . c om*/ // Load defaults from resources final Resources res = getResources(); final int defaultFooterColor = res.getColor(context.getResources() .getIdentifier("default_title_indicator_footer_color", "color", context.getPackageName())); // final int defaultFooterColor = res // .getColor(R.color.default_title_indicator_footer_color); final float defaultFooterLineHeight = res.getDimension(context.getResources() .getIdentifier("default_title_indicator_footer_line_height", "dimen", context.getPackageName())); // final float defaultFooterLineHeight = res // .getDimension(R.dimen.default_title_indicator_footer_line_height); final int defaultFooterIndicatorStyle = res.getInteger(context.getResources().getIdentifier( "default_title_indicator_footer_indicator_style", "integer", context.getPackageName())); // final int defaultFooterIndicatorStyle = res // .getInteger(R.integer.default_title_indicator_footer_indicator_style); final float defaultFooterIndicatorHeight = res.getDimension(context.getResources().getIdentifier( "default_title_indicator_footer_indicator_height", "dimen", context.getPackageName())); // final float defaultFooterIndicatorHeight = res // .getDimension(R.dimen.default_title_indicator_footer_indicator_height); final float defaultFooterIndicatorUnderlinePadding = res.getDimension(context.getResources().getIdentifier( "default_title_indicator_footer_indicator_underline_padding", "dimen", context.getPackageName())); // final float defaultFooterIndicatorUnderlinePadding = res // .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding); final float defaultFooterPadding = res.getDimension(context.getResources() .getIdentifier("default_title_indicator_footer_padding", "dimen", context.getPackageName())); // final float defaultFooterPadding = res // .getDimension(R.dimen.default_title_indicator_footer_padding); final int defaultLinePosition = res.getInteger(context.getResources() .getIdentifier("default_title_indicator_line_position", "integer", context.getPackageName())); // final int defaultLinePosition = res // .getInteger(R.integer.default_title_indicator_line_position); final int defaultSelectedColor = res.getColor(context.getResources() .getIdentifier("default_title_indicator_selected_color", "color", context.getPackageName())); // final int defaultSelectedColor = res // .getColor(R.color.default_title_indicator_selected_color); final boolean defaultSelectedBold = res.getBoolean(context.getResources() .getIdentifier("default_title_indicator_selected_bold", "bool", context.getPackageName())); // final boolean defaultSelectedBold = res // .getBoolean(R.bool.default_title_indicator_selected_bold); final int defaultTextColor = res.getColor(context.getResources() .getIdentifier("default_title_indicator_text_color", "color", context.getPackageName())); // final int defaultTextColor = res // .getColor(R.color.default_title_indicator_text_color); final float defaultTextSize = res.getDimension(context.getResources() .getIdentifier("default_title_indicator_text_size", "dimen", context.getPackageName())); // final float defaultTextSize = res // .getDimension(R.dimen.default_title_indicator_text_size); final float defaultTitlePadding = res.getDimension(context.getResources() .getIdentifier("default_title_indicator_title_padding", "dimen", context.getPackageName())); // final float defaultTitlePadding = res // .getDimension(R.dimen.default_title_indicator_title_padding); final float defaultClipPadding = res.getDimension(context.getResources() .getIdentifier("default_title_indicator_clip_padding", "dimen", context.getPackageName())); // final float defaultClipPadding = res // .getDimension(R.dimen.default_title_indicator_clip_padding); final float defaultTopPadding = res.getDimension(context.getResources() .getIdentifier("default_title_indicator_top_padding", "dimen", context.getPackageName())); // final float defaultTopPadding = res // .getDimension(R.dimen.default_title_indicator_top_padding); // Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, new int[] { getResources().getIdentifier("TitlePageIndicator", "styleable", context.getPackageName()) }, defStyle, 0); // TypedArray a = context.obtainStyledAttributes(attrs, // R.styleable.TitlePageIndicator, defStyle, 0); // Retrieve the colors to be used for this view and apply them. mFooterLineHeight = a.getDimension(getResources().getIdentifier("TitlePageIndicator_footerLineHeight", "styleable", context.getPackageName()), defaultFooterLineHeight); // mFooterLineHeight = a.getDimension( // R.styleable.TitlePageIndicator_footerLineHeight, // defaultFooterLineHeight); mFooterIndicatorStyle = IndicatorStyle .fromValue(a.getInteger(getResources().getIdentifier("TitlePageIndicator_footerIndicatorStyle", "styleable", context.getPackageName()), defaultFooterIndicatorStyle)); // mFooterIndicatorStyle = IndicatorStyle.fromValue(a.getInteger( // R.styleable.TitlePageIndicator_footerIndicatorStyle, // defaultFooterIndicatorStyle)); mFooterIndicatorHeight = a.getDimension(getResources() .getIdentifier("TitlePageIndicator_footerIndicatorHeight", "styleable", context.getPackageName()), defaultFooterIndicatorHeight); // mFooterIndicatorHeight = a.getDimension( // R.styleable.TitlePageIndicator_footerIndicatorHeight, // defaultFooterIndicatorHeight); mFooterIndicatorUnderlinePadding = a .getDimension(getResources().getIdentifier("TitlePageIndicator_footerIndicatorUnderlinePadding", "styleable", context.getPackageName()), defaultFooterIndicatorUnderlinePadding); // mFooterIndicatorUnderlinePadding = a.getDimension( // R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, // defaultFooterIndicatorUnderlinePadding); mFooterPadding = a.getDimension(getResources().getIdentifier("TitlePageIndicator_footerPadding", "styleable", context.getPackageName()), defaultFooterPadding); // mFooterPadding = a.getDimension( // R.styleable.TitlePageIndicator_footerPadding, // defaultFooterPadding); mLinePosition = LinePosition .fromValue(a.getInteger(getResources().getIdentifier("TitlePageIndicator_linePosition", "styleable", context.getPackageName()), defaultLinePosition)); // mLinePosition = LinePosition.fromValue(a.getInteger( // R.styleable.TitlePageIndicator_linePosition, // defaultLinePosition)); mTopPadding = a.getDimension(getResources().getIdentifier("TitlePageIndicator_topPadding", "styleable", context.getPackageName()), defaultTopPadding); // mTopPadding = // a.getDimension(R.styleable.TitlePageIndicator_topPadding, // defaultTopPadding); mTitlePadding = a.getDimension(getResources().getIdentifier("TitlePageIndicator_titlePadding", "styleable", context.getPackageName()), defaultTitlePadding); // mTitlePadding = a.getDimension( // R.styleable.TitlePageIndicator_titlePadding, // defaultTitlePadding); mClipPadding = a.getDimension(getResources().getIdentifier("TitlePageIndicator_clipPadding", "styleable", context.getPackageName()), defaultClipPadding); // mClipPadding = a.getDimension( // R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding); mColorSelected = a.getColor(getResources().getIdentifier("TitlePageIndicator_selectedColor", "styleable", context.getPackageName()), defaultSelectedColor); // mColorSelected = a.getColor( // R.styleable.TitlePageIndicator_selectedColor, // defaultSelectedColor); mColorText = a.getColor(getResources().getIdentifier("TitlePageIndicator_android_textColor", "styleable", context.getPackageName()), defaultTextColor); // mColorText = a.getColor( // R.styleable.TitlePageIndicator_android_textColor, // defaultTextColor); mBoldText = a.getBoolean(getResources().getIdentifier("TitlePageIndicator_selectedBold", "styleable", context.getPackageName()), defaultSelectedBold); // mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, // defaultSelectedBold); final float textSize = a.getDimension(getResources().getIdentifier("TitlePageIndicator_android_textSize", "styleable", context.getPackageName()), defaultTextSize); // final float textSize = a.getDimension( // R.styleable.TitlePageIndicator_android_textSize, // defaultTextSize); final int footerColor = a.getColor(getResources().getIdentifier("TitlePageIndicator_footerColor", "styleable", context.getPackageName()), defaultFooterColor); // final int footerColor = a.getColor( // R.styleable.TitlePageIndicator_footerColor, defaultFooterColor); mPaintText.setTextSize(textSize); mPaintText.setAntiAlias(true); mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterLine.setStrokeWidth(mFooterLineHeight); mPaintFooterLine.setColor(footerColor); mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterIndicator.setColor(footerColor); Drawable background = a.getDrawable(getResources().getIdentifier("TitlePageIndicator_android_background", "styleable", context.getPackageName())); // Drawable background = a // .getDrawable(R.styleable.TitlePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.leeon.blank.widget.RangeBarNew.java
private void applyConfig(Context context, AttributeSet attrs) { if (attrs == null) { return;//from ww w. ja va 2s . com } TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RangeBar); indicatorDrawable = a.getDrawable(R.styleable.RangeBar_indicatorDrawable); mLeftCursorBG = a.getDrawable(R.styleable.RangeBar_leftCursorBackground); mRightCursorBG = a.getDrawable(R.styleable.RangeBar_rightCursorBackground); mTextColorNormal = a.getColor(R.styleable.RangeBar_textColorNormal, Color.GRAY); mRangeBarColorNormal = a.getColor(R.styleable.RangeBar_barColorNormal, Color.rgb(218, 215, 215)); mRangeBarColorSelected = a.getColor(R.styleable.RangeBar_barColorSelected, Color.rgb(197, 0, 0)); mRangeBarHeight = (int) a.getDimension(R.styleable.RangeBar_barHeight, 10); mTextSize = (int) a.getDimension(R.styleable.RangeBar_textSize, 14); mMarginBetween = (int) a.getDimension(R.styleable.RangeBar_spaceBetween, 16); isInfinite = a.getBoolean(R.styleable.RangeBar_isInfinite, true); CharSequence[] charArray = a.getTextArray(R.styleable.RangeBar_markTextArray); if (null == charArray || charArray.length <= 1) { throw new IllegalArgumentException("markTextArray should at least have 2 number!"); } mTextArray = new int[isInfinite ? charArray.length + 1 : charArray.length]; for (int i = 0; i < charArray.length; i++) { mTextArray[i] = Integer.parseInt(charArray[i].toString()); if (mTextArray[i] < 0) { throw new IllegalArgumentException("markTextArray must be a positive number array"); } } if (isInfinite) { mTextArray[charArray.length] = -1; } mLeftCursorIndex = 0; mRightCursorIndex = (mTextArray.length - 1) * 5; mRightCursorNextIndex = mRightCursorIndex; a.recycle(); }
From source file:com.xiaoyu.erbao.cctrls.SlidingLayer.java
public SlidingLayer(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingLayer); //setStickTo(ta.getInt(R.styleable.SlidingLayer_stickTo, STICK_TO_RIGHT)); int shadowRes = ta.getResourceId(R.styleable.SlidingLayer_shadowDrawable, INVALID_VALUE); if (shadowRes != INVALID_VALUE) { setShadowDrawable(shadowRes);/*from w w w .j a va 2s . co m*/ } mShadowSize = (int) ta.getDimension(R.styleable.SlidingLayer_shadowSize, 0); changeStateOnTap = ta.getBoolean(R.styleable.SlidingLayer_changeStateOnTap, true); ta.recycle(); init(); }
From source file:com.zzti.fyg.widgets.SwipeRefreshLayout.java
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. * // w w w.j a va2 s . c om * @param context * @param attrs */ public SwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_longAnimTime); setWillNotDraw(false); final DisplayMetrics metrics = getResources().getDisplayMetrics(); mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); //screenWidth = metrics.widthPixels; trigger_angle = Math.atan((double) metrics.widthPixels / metrics.heightPixels); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.swiperefresh); // setEnabled(a.getBoolean(0, true)); setEnabled(true); ptr_drawable = a.getResourceId(R.styleable.swiperefresh_roateImage, R.drawable.default_ptr_rotate); ptr_flip_drawable = a.getResourceId(R.styleable.swiperefresh_flipImage, R.drawable.default_ptr_flip); finished_drawable = a.getResourceId(R.styleable.swiperefresh_finishedImage, R.drawable.ic_done_grey600_18dp); pull2refresh = a.getBoolean(R.styleable.swiperefresh_ptr, true); pull2load = a.getBoolean(R.styleable.swiperefresh_ptl, true); textSize = a.getDimension(R.styleable.swiperefresh_srlTextSize, DEFAULT_TIPS_TEXTSIZE * metrics.density); textColor = a.getColor(R.styleable.swiperefresh_srlTextColor, DEFAULT_TEXT_COLOR); type = a.getInt(R.styleable.swiperefresh_srlAnimationStyle, DEFAULT_TYPE); pullDownLabel = a.getString(R.styleable.swiperefresh_pullDownLabel); refreshingLabel = a.getString(R.styleable.swiperefresh_refreshingLabel); releaseDownLabel = a.getString(R.styleable.swiperefresh_releaseDownLabel); pullUpLabel = a.getString(R.styleable.swiperefresh_pullUpLabel); loadingLabel = a.getString(R.styleable.swiperefresh_loadingLabel); releaseUpLabel = a.getString(R.styleable.swiperefresh_releaseUpLabel); if (null == pullDownLabel || pullDownLabel.equals("")) { pullDownLabel = DEFAULT_PULL_DOWN_LABEL; } if (null == refreshingLabel || refreshingLabel.equals("")) { refreshingLabel = DEFAULT_REFRESHING_LABEL; } if (null == releaseDownLabel || releaseDownLabel.equals("")) { releaseDownLabel = DEFAULT_RELEASE_DOWN_LABEL; } if (null == pullUpLabel || pullUpLabel.equals("")) { pullUpLabel = DEFAULT_PULL_UP_LABEL; } if (null == loadingLabel || loadingLabel.equals("")) { loadingLabel = DEFAULT_LOADING_LABEL; } if (null == releaseUpLabel || releaseUpLabel.equals("")) { releaseUpLabel = DEFAULT_RELEASE_UP_LABEL; } mProgressBar = new SwipeProgressBar(this, textSize, textColor, ptr_drawable, ptr_flip_drawable, finished_drawable, type); a.recycle(); }