List of usage examples for android.content.res TypedArray getBoolean
public boolean getBoolean(@StyleableRes int index, boolean defValue)
From source file:android_hddl_framework.viewpagerindicator.LinePageIndicator.java
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/* w w w . j av a 2s . 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.app.laundry.tabs.lib.LinePageIndicator2.java
public LinePageIndicator2(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;// www . j a v a 2s. 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.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.along.altmcssd.pda.widget.viewpagerindicator.LinePageIndicator.java
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//from www . j av a2s . 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.cleveroad.slidingtutorial.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;// w w w . ja v a2 s .co m //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = ContextCompat.getColor(context, R.color.st_default_circle_indicator_page_color); final int defaultFillColor = ContextCompat.getColor(context, R.color.st_default_circle_indicator_fill_color); final int defaultOrientation = res.getInteger(R.integer.st_default_circle_indicator_orientation); final int defaultStrokeColor = ContextCompat.getColor(context, R.color.st_default_circle_indicator_stroke_color); final float defaultStrokeWidth = res.getDimension(R.dimen.st_default_circle_indicator_stroke_width); final float defaultRadius = res.getDimension(R.dimen.st_default_circle_indicator_radius); final boolean defaultCentered = res.getBoolean(R.bool.st_default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(R.bool.st_default_circle_indicator_snap); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_st_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_st_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_st_strokeColor, defaultStrokeColor)); mPaintStroke .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_st_strokeWidth, defaultStrokeWidth)); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_st_fillColor, defaultFillColor)); mRadius = a.getDimension(R.styleable.CirclePageIndicator_st_radius, defaultRadius); mSnap = a.getBoolean(R.styleable.CirclePageIndicator_st_snap, defaultSnap); Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background); if (background != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { setBackground(background); } else { //noinspection deprecation setBackgroundDrawable(background); } } a.recycle(); }
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 ww w . ja v a2s .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:cn.bvin.app.swiperefresh.OldSwipeRefreshLayout.java
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. * * @param context//ww w. jav a2s .c o m * @param attrs */ public OldSwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime); setWillNotDraw(false); mProgressBar = new SwipeProgressBar(this); final DisplayMetrics metrics = getResources().getDisplayMetrics(); mProgressBarHeight = (int) (metrics.density * PROGRESS_BAR_HEIGHT); mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_INTERPOLATION_FACTOR); final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); setEnabled(a.getBoolean(0, true)); a.recycle(); }
From source file:com.actionbarsherlock.internal.view.menu.ListMenuItemView.java
public ListMenuItemView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs); mContext = context;//from w ww .j ava2 s .co m TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockMenuView, defStyle, 0); mBackground = a.getDrawable(R.styleable.SherlockMenuView_itemBackground); mTextAppearance = a.getResourceId(R.styleable.SherlockMenuView_itemTextAppearance, -1); mPreserveIconSpacing = a.getBoolean(R.styleable.SherlockMenuView_preserveIconSpacing, false); mTextAppearanceContext = context; a.recycle(); }
From source file:com.android.yijiang.kzx.widget.tab.PagerSlidingTabStrip.java
public PagerSlidingTabStrip(Context context, AttributeSet attrs) { super(context, attrs); setHorizontalScrollBarEnabled(false); //?????? if (attrs != null) { TypedArray attrsTypedArray = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip); if (attrsTypedArray != null) { allowWidthFull = attrsTypedArray.getBoolean(R.styleable.PagerSlidingTabStrip_allowWidthFull, false); slidingBlockDrawable = attrsTypedArray.getDrawable(R.styleable.PagerSlidingTabStrip_slidingBlock); attrsTypedArray.recycle();/* w ww . j a va 2 s .co m*/ } } }
From source file:cn.tan.lib.widget.DrawShadowFrameLayout.java
public DrawShadowFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DrawShadowFrameLayout, 0, 0); mShadowDrawable = a.getDrawable(R.styleable.DrawShadowFrameLayout_shadowDrawable); if (mShadowDrawable != null) { mShadowDrawable.setCallback(this); if (mShadowDrawable instanceof NinePatchDrawable) { mShadowNinePatchDrawable = (NinePatchDrawable) mShadowDrawable; }//from w w w . j av a 2s . c o m } mShadowVisible = a.getBoolean(R.styleable.DrawShadowFrameLayout_shadowVisible, true); setWillNotDraw(!mShadowVisible || mShadowDrawable == null); a.recycle(); }
From source file:com.easemob.easeui.widget.viewpagerindicator.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs) { super(context, attrs); if (isInEditMode()) return;// w ww.j ava 2 s. co m TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleIndicator); mCentered = a.getBoolean(R.styleable.CircleIndicator_mCentered, true); mOrientation = a.getInt(R.styleable.CircleIndicator_android_orientation, 0); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.CircleIndicator_mPageColor, 0xa0000000)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CircleIndicator_mStrokeColor, 0xFFDDDDDD)); mPaintStroke.setStrokeWidth(0); // 1dip mPaintFill.setStyle(Style.FILL); mPaintFill.setColor(a.getColor(R.styleable.CircleIndicator_mFillColor, 0xFFff5f19)); // 0xFFFFFFFF mRadius = a.getDimension(R.styleable.CircleIndicator_mRadius, 20); //3dip mSnap = a.getBoolean(R.styleable.CircleIndicator_mSnap, true); Drawable background = a.getDrawable(R.styleable.CircleIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }