List of usage examples for android.content.res Resources getBoolean
public boolean getBoolean(@BoolRes int id) throws NotFoundException
From source file:com.maedi.user.godok.v1.viewpagerindicator.CirclePageIndicator.java
@SuppressWarnings("deprecation") public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;// w w w .j av a 2 s .c om //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res .getColor(com.viewpagerindicator.R.color.default_circle_indicator_page_color); final int defaultFillColor = res .getColor(com.viewpagerindicator.R.color.default_circle_indicator_fill_color); final int defaultOrientation = res .getInteger(com.viewpagerindicator.R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = res .getColor(com.viewpagerindicator.R.color.default_circle_indicator_stroke_color); final float defaultStrokeWidth = res .getDimension(com.viewpagerindicator.R.dimen.default_circle_indicator_stroke_width); final float defaultRadius = res .getDimension(com.viewpagerindicator.R.dimen.default_circle_indicator_radius); final boolean defaultCentered = res .getBoolean(com.viewpagerindicator.R.bool.default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(com.viewpagerindicator.R.bool.default_circle_indicator_snap); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, com.viewpagerindicator.R.styleable.CirclePageIndicator, defStyle, 0); mCentered = a.getBoolean(com.viewpagerindicator.R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(com.viewpagerindicator.R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor( a.getColor(com.viewpagerindicator.R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor( a.getColor(com.viewpagerindicator.R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke.setStrokeWidth(a.getDimension( com.viewpagerindicator.R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor( a.getColor(com.viewpagerindicator.R.styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(com.viewpagerindicator.R.styleable.CirclePageIndicator_radius, defaultRadius); mSnap = a.getBoolean(com.viewpagerindicator.R.styleable.CirclePageIndicator_snap, defaultSnap); Drawable background = a .getDrawable(com.viewpagerindicator.R.styleable.CirclePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.qifeng.theunderseaworld.view.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*from w w w. ja va 2 s . c o m*/ //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res .getColor(com.viewpagerindicator.R.color.default_circle_indicator_page_color); final int defaultFillColor = res .getColor(com.viewpagerindicator.R.color.default_circle_indicator_fill_color); final int defaultOrientation = res .getInteger(com.viewpagerindicator.R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = res .getColor(com.viewpagerindicator.R.color.default_circle_indicator_stroke_color); final float defaultStrokeWidth = res .getDimension(com.viewpagerindicator.R.dimen.default_circle_indicator_stroke_width); final float defaultRadius = res .getDimension(com.viewpagerindicator.R.dimen.default_circle_indicator_radius); final boolean defaultCentered = res .getBoolean(com.viewpagerindicator.R.bool.default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(com.viewpagerindicator.R.bool.default_circle_indicator_snap); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, com.viewpagerindicator.R.styleable.CirclePageIndicator, defStyle, 0); mCentered = a.getBoolean(com.viewpagerindicator.R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(com.viewpagerindicator.R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Paint.Style.FILL); mPaintPageFill.setColor( a.getColor(com.viewpagerindicator.R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Paint.Style.STROKE); mPaintStroke.setColor( a.getColor(com.viewpagerindicator.R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke.setStrokeWidth(a.getDimension( com.viewpagerindicator.R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill.setStyle(Paint.Style.FILL); mPaintFill.setColor( a.getColor(com.viewpagerindicator.R.styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(com.viewpagerindicator.R.styleable.CirclePageIndicator_radius, defaultRadius); mSnap = a.getBoolean(com.viewpagerindicator.R.styleable.CirclePageIndicator_snap, defaultSnap); Drawable background = a .getDrawable(com.viewpagerindicator.R.styleable.CirclePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:no.srib.app.client.view.CircleIshPageIndicator.java
public CircleIshPageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//from w w w . j a v a 2s . co m //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res .getColor(com.viewpagerindicator.R.color.default_circle_indicator_page_color); final int defaultFillColor = res .getColor(com.viewpagerindicator.R.color.default_circle_indicator_fill_color); final int defaultOrientation = res .getInteger(com.viewpagerindicator.R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = res .getColor(com.viewpagerindicator.R.color.default_circle_indicator_stroke_color); final float defaultStrokeWidth = res .getDimension(com.viewpagerindicator.R.dimen.default_circle_indicator_stroke_width); final float defaultRadius = res .getDimension(com.viewpagerindicator.R.dimen.default_circle_indicator_radius); final boolean defaultCentered = res .getBoolean(com.viewpagerindicator.R.bool.default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(com.viewpagerindicator.R.bool.default_circle_indicator_snap); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, com.viewpagerindicator.R.styleable.CirclePageIndicator, defStyle, 0); mCentered = a.getBoolean(com.viewpagerindicator.R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(com.viewpagerindicator.R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor( a.getColor(com.viewpagerindicator.R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor( a.getColor(com.viewpagerindicator.R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke.setStrokeWidth(a.getDimension( com.viewpagerindicator.R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor( a.getColor(com.viewpagerindicator.R.styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(com.viewpagerindicator.R.styleable.CirclePageIndicator_radius, defaultRadius); mSnap = a.getBoolean(com.viewpagerindicator.R.styleable.CirclePageIndicator_snap, defaultSnap); Drawable background = a .getDrawable(com.viewpagerindicator.R.styleable.CirclePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); circle = BitmapFactory.decodeResource(res, R.drawable.ic_viewpager); selected = BitmapFactory.decodeResource(res, R.drawable.ic_viewpager_selected); }
From source file:me.futuretechnology.util.ui.TitlePageIndicator.java
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) { return;/*from ww w .jav a2 s .c o m*/ } // TODO clean this up // Load defaults from resources Resources res = getResources(); int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color); float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height); float defaultFooterIndicatorHeight = res .getDimension(R.dimen.default_title_indicator_footer_indicator_height); float defaultFooterIndicatorUnderlinePadding = res .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding); float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding); int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color); boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold); int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color); float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size); float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding); float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding); float defaultTopPadding = res.getDimension(R.dimen.default_title_indicator_top_padding); // Retrieve styles attributes 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(R.styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight); mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight, defaultFooterIndicatorHeight); mFooterIndicatorUnderlinePadding = a.getDimension( R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, defaultFooterIndicatorUnderlinePadding); mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding); mTopPadding = a.getDimension(R.styleable.TitlePageIndicator_topPadding, defaultTopPadding); mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding); mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding); mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor); mColorText = a.getColor(R.styleable.TitlePageIndicator_textColor, defaultTextColor); mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold); float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize); int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor); mPaintText.setTextSize(textSize); mPaintText.setAntiAlias(true); mPaintText.setDither(true); mPaintText.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL)); mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); // noinspection SuspiciousNameCombination mPaintFooterLine.setStrokeWidth(mFooterLineHeight); mPaintFooterLine.setColor(footerColor); mPaintFooterIndicator.setDither(true); // http://code.google.com/p/android/issues/detail?id=24873 // bug when enabling hardware acceleration // workaround #1: disable hw acceleration => the drawing will be rough // setLayerType(View.LAYER_TYPE_SOFTWARE, mPaintFooterIndicator); // workaround #2: avoid using 0 as stroke width => the drawing will be smooth as butter mPaintFooterIndicator.setStrokeWidth(1); mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterIndicator.setColor(footerColor); a.recycle(); ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.sim2dial.dialer.InCallActivity.java
private void setContactName(LinearLayout callView, LinphoneAddress lAddress, String sipUri, Resources resources) { TextView contact = (TextView) callView.findViewById(R.id.contactNameOrNumber); if (lAddress.getDisplayName() == null) { if (resources.getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) { contact.setText(LinphoneUtils.getUsernameFromAddress(sipUri)); } else {//from ww w . ja v a2 s . c o m contact.setText(LinphoneUtils.getUsernameFromAddress(sipUri)); } } else { contact.setText(lAddress.getDisplayName()); } }
From source file:com.androzic.MapFragment.java
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Resources resources = getResources(); if (getString(R.string.pref_wakelock).equals(key)) { keepScreenOn = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_wakelock)); map.setKeepScreenOn(keepScreenOn); } else if (getString(R.string.pref_showdistance_int).equals(key)) { showDistance = Integer.parseInt(sharedPreferences.getString(key, getString(R.string.def_showdistance))); } else if (getString(R.string.pref_hidemapinfo).equals(key)) { mapInfoHideDelay = Integer.parseInt(sharedPreferences.getString(key, "2147483647")); } else if (getString(R.string.pref_hidesatinfo).equals(key)) { satInfoHideDelay = Integer.parseInt(sharedPreferences.getString(key, "2147483647")); } else if (getString(R.string.pref_hidenavinfo).equals(key)) { navInfoHideDelay = Integer.parseInt(sharedPreferences.getString(key, "2147483647")); } else if (getString(R.string.pref_maprenderinterval).equals(key)) { updatePeriod = sharedPreferences.getInt(key, resources.getInteger(R.integer.def_maprenderinterval)) * 100;// www . j a v a 2 s .co m } else if (getString(R.string.pref_mapfollowonloc).equals(key)) { followOnLocation = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapfollowonloc)); } else if (getString(R.string.pref_mapdiminterval).equals(key)) { dimInterval = sharedPreferences.getInt(key, resources.getInteger(R.integer.def_mapdiminterval)) * 1000; } else if (getString(R.string.pref_mapdimvalue).equals(key)) { dimValue = sharedPreferences.getInt(key, resources.getInteger(R.integer.def_mapdimvalue)); } else if (getString(R.string.pref_mapdim).equals(key)) { autoDim = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapdim)); dimScreen(); } else if (getString(R.string.pref_unfollowontap).equals(key)) { map.setStrictUnfollow( !sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_unfollowontap))); } else if (getString(R.string.pref_lookahead).equals(key)) { map.setLookAhead(sharedPreferences.getInt(key, resources.getInteger(R.integer.def_lookahead))); } else if (getString(R.string.pref_mapbest).equals(key)) { map.setBestMapEnabled(sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapbest))); } else if (getString(R.string.pref_mapbestinterval).equals(key)) { map.setBestMapInterval( sharedPreferences.getInt(key, resources.getInteger(R.integer.def_mapbestinterval)) * 1000); } else if (getString(R.string.pref_scalebarbg).equals(key)) { map.setDrawScaleBarBackground( sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_scalebarbg))); } else if (getString(R.string.pref_scalebarcolor).equals(key)) { map.setScaleBarColor(sharedPreferences.getInt(key, resources.getColor(R.color.scalebar))); } else if (getString(R.string.pref_scalebarbgcolor).equals(key)) { map.setScaleBarBackgroundColor(sharedPreferences.getInt(key, resources.getColor(R.color.scalebarbg))); } else if (getString(R.string.pref_hidemapcross).equals(key)) { int delay = Integer.parseInt(sharedPreferences.getString(key, "5")); map.setCrossCursorHideDelay(delay); } else if (getString(R.string.pref_mapcrosscolor).equals(key)) { map.setCrossColor(sharedPreferences.getInt(key, resources.getColor(R.color.mapcross))); } else if (getString(R.string.pref_cursorvector).equals(key) || getString(R.string.pref_cursorvectormlpr).equals(key)) { map.setCursorVector( Integer.parseInt(sharedPreferences.getString(getString(R.string.pref_cursorvector), getString(R.string.def_cursorvector))), sharedPreferences.getInt(getString(R.string.pref_cursorvectormlpr), resources.getInteger(R.integer.def_cursorvectormlpr))); } else if (getString(R.string.pref_cursorcolor).equals(key)) { map.setCursorColor(sharedPreferences.getInt(key, resources.getColor(R.color.cursor))); } else if (getString(R.string.pref_navigation_proximity).equals(key)) { map.setProximity(Integer .parseInt(sharedPreferences.getString(key, getString(R.string.def_navigation_proximity)))); } else if (getString(R.string.pref_unitspeed).equals(key)) { speedUnit.setText(StringFormatter.speedAbbr); } else if (getString(R.string.pref_unitelevation).equals(key)) { elevationUnit.setText(StringFormatter.elevationAbbr); } else if (getString(R.string.pref_unitangle).equals(key)) { trackUnit.setText(StringFormatter.angleAbbr); bearingUnit.setText(StringFormatter.angleAbbr); turnUnit.setText(StringFormatter.angleAbbr); } }
From source file:org.xingjitong.InCallActivity.java
private void setContactPhone(LinearLayout callView, LinphoneAddress lAddress, String sipUri, Resources resources) { TextView contact = (TextView) callView.findViewById(R.id.contactNameOrNumber); if (lAddress.getDisplayName() == null) { if (resources.getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) { contact.setText(LinphoneUtils.getUsernameFromAddress(sipUri)); } else {/*from w ww .j a v a2 s .co m*/ contact.setText(sipUri); } } else { contact.setText(lAddress.getDisplayName()); } String p = contact.getText().toString(); if (p.startsWith("01") && !p.startsWith("010")) { p = p.substring(1); } else if (p.startsWith("51201")) { p = p.substring(4); } else if (p.startsWith("512")) { p = p.substring(3); } if ("00000000".equals(p)) { p = "??"; } contact.setText(p); }
From source file:com.jakewharton.android.viewpagerindicator.TitlePageIndicator.java
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //Load defaults from resources final Resources res = getResources(); final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color); final float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height); final int defaultFooterIndicatorStyle = res .getInteger(R.integer.default_title_indicator_footer_indicator_style); final float defaultFooterIndicatorHeight = res .getDimension(R.dimen.default_title_indicator_footer_indicator_height); final float defaultFooterIndicatorUnderlinePadding = res .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding); final float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding); final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color); final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold); final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color); final float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size); final float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding); final float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle, R.style.Widget_TitlePageIndicator); //Retrieve the colors to be used for this view and apply them. mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight);//from ww w. ja v a 2 s . c o m mFooterIndicatorStyle = IndicatorStyle.fromValue( a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle)); mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight, defaultFooterIndicatorHeight); mFooterIndicatorUnderlinePadding = a.getDimension( R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, defaultFooterIndicatorUnderlinePadding); mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding); mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding); mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding); mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor); mColorText = a.getColor(R.styleable.TitlePageIndicator_textColor, defaultTextColor); mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold); final float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize); final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor); mPaintText = new Paint(); mPaintText.setTextSize(textSize); mPaintText.setAntiAlias(true); mPaintFooterLine = new Paint(); mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterLine.setStrokeWidth(mFooterLineHeight); mPaintFooterLine.setColor(footerColor); mPaintFooterIndicator = new Paint(); mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterIndicator.setColor(footerColor); a.recycle(); }
From source file:com.fanfou.app.opensource.ui.viewpager.TitlePageIndicator.java
public TitlePageIndicator(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); // Load defaults from resources final Resources res = getResources(); final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color); final float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height); final int defaultFooterIndicatorStyle = res .getInteger(R.integer.default_title_indicator_footer_indicator_style); final float defaultFooterIndicatorHeight = res .getDimension(R.dimen.default_title_indicator_footer_indicator_height); final float defaultFooterIndicatorUnderlinePadding = res .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding); final float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding); final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color); final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold); final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color); final float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size); final float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding); final float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding); // Retrieve styles attributes final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle, R.style.Widget_TitlePageIndicator); // Retrieve the colors to be used for this view and apply them. this.mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight);/*from w w w .j av a2 s. c o m*/ this.mFooterIndicatorStyle = IndicatorStyle.fromValue( a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle)); this.mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight, defaultFooterIndicatorHeight); this.mFooterIndicatorUnderlinePadding = a.getDimension( R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, defaultFooterIndicatorUnderlinePadding); this.mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding); this.mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding); this.mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding); this.mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor); this.mColorText = a.getColor(R.styleable.TitlePageIndicator_textColor, defaultTextColor); this.mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold); final float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize); final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor); this.mPaintText = new Paint(); this.mPaintText.setTextSize(textSize); this.mPaintText.setAntiAlias(true); this.mPaintFooterLine = new Paint(); this.mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); this.mPaintFooterLine.setStrokeWidth(this.mFooterLineHeight); this.mPaintFooterLine.setColor(footerColor); this.mPaintFooterIndicator = new Paint(); this.mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); this.mPaintFooterIndicator.setColor(footerColor); a.recycle(); this.mPath = new Path(); }
From source file:com.lbk.app.weiliao.ui.views.TitlePageIndicator.java
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //Load defaults from resources final Resources res = getResources(); final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color); final float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height); final int defaultFooterIndicatorStyle = res .getInteger(R.integer.default_title_indicator_footer_indicator_style); final float defaultFooterIndicatorHeight = res .getDimension(R.dimen.default_title_indicator_footer_indicator_height); final float defaultFooterIndicatorUnderlinePadding = res .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding); final float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding); final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color); final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold); final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color); final float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size); final float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding); final float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding); final float defaultTopPadding = res.getDimension(R.dimen.default_title_indicator_top_padding); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle, R.style.Widget_TitlePageIndicator); //Retrieve the colors to be used for this view and apply them. mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight);// ww w . ja v a 2 s .co m mFooterIndicatorStyle = IndicatorStyle.fromValue( a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle)); mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight, defaultFooterIndicatorHeight); mFooterIndicatorUnderlinePadding = a.getDimension( R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, defaultFooterIndicatorUnderlinePadding); mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding); mTopPadding = a.getDimension(R.styleable.TitlePageIndicator_topPadding, defaultTopPadding); mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding); mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding); mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor); mColorText = a.getColor(R.styleable.TitlePageIndicator_textColor, defaultTextColor); mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold); final float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize); final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor); mPaintText = new Paint(); mPaintText.setTextSize(textSize); mPaintText.setAntiAlias(true); mPaintFooterLine = new Paint(); mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterLine.setStrokeWidth(mFooterLineHeight); mPaintFooterLine.setColor(footerColor); mPaintFooterIndicator = new Paint(); mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterIndicator.setColor(footerColor); a.recycle(); }