List of usage examples for android.content.res TypedArray getDrawable
@Nullable public Drawable getDrawable(@StyleableRes int index)
From source file:com.lyric.indicator.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//from ww w. j a va2 s . c o m //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, 0); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); 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); Drawable background = a.getDrawable(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.appeaser.sublimenavigationviewlibrary.SublimeNavigationView.java
public SublimeNavigationView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.SublimeNavigationView, defStyleAttr, R.style.SnvSublimeNavigationView); try {/*from www.j a v a 2 s . com*/ // Used for creating default resources SublimeThemer.DefaultTheme defaultTheme = SublimeThemer.DefaultTheme.LIGHT; if (a.hasValue(R.styleable.SublimeNavigationView_snvDefaultTheme)) { defaultTheme = a.getInt(R.styleable.SublimeNavigationView_snvDefaultTheme, 0) == 0 ? SublimeThemer.DefaultTheme.LIGHT : SublimeThemer.DefaultTheme.DARK; } mThemer = new SublimeThemer(getContext(), defaultTheme); mThemer.setDrawerBackground(a.getDrawable(R.styleable.SublimeNavigationView_android_background)); if (a.hasValue(R.styleable.SublimeNavigationView_elevation)) { mThemer.setElevation( (float) a.getDimensionPixelSize(R.styleable.SublimeNavigationView_elevation, 0)); } ViewCompat.setFitsSystemWindows(this, a.getBoolean(R.styleable.SublimeNavigationView_android_fitsSystemWindows, false)); mMaxWidth = a.getDimensionPixelSize(R.styleable.SublimeNavigationView_android_maxWidth, 0); if (a.hasValue(R.styleable.SublimeNavigationView_snvItemIconTint)) { mThemer.setIconTintList(a.getColorStateList(R.styleable.SublimeNavigationView_snvItemIconTint)); } mThemer.setGroupExpandDrawable(a.getDrawable(R.styleable.SublimeNavigationView_snvGroupExpandDrawable)); mThemer.setGroupCollapseDrawable( a.getDrawable(R.styleable.SublimeNavigationView_snvGroupCollapseDrawable)); // Text style profiles for Item, Hint, SubheaderItem & SubheaderHint ColorStateList itemTextColor = null, hintTextColor = null, subheaderItemTextColor = null, subheaderHintTextColor = null, badgeTextColor = null; Typeface itemTypeface = null, hintTypeface = null, subheaderItemTypeface = null, subheaderHintTypeface = null, badgeTypeface = null; int itemTypefaceStyle = 0, hintTypefaceStyle = 0, subheaderItemTypefaceStyle = 0, subheaderHintTypefaceStyle = 0, badgeTypefaceStyle = 0; if (a.hasValue(R.styleable.SublimeNavigationView_snvItemTextColor)) { itemTextColor = a.getColorStateList(R.styleable.SublimeNavigationView_snvItemTextColor); } if (a.hasValue(R.styleable.SublimeNavigationView_snvHintTextColor)) { hintTextColor = a.getColorStateList(R.styleable.SublimeNavigationView_snvHintTextColor); } if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderItemTextColor)) { subheaderItemTextColor = a .getColorStateList(R.styleable.SublimeNavigationView_snvSubheaderItemTextColor); } if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderHintTextColor)) { subheaderHintTextColor = a .getColorStateList(R.styleable.SublimeNavigationView_snvSubheaderHintTextColor); } if (a.hasValue(R.styleable.SublimeNavigationView_snvBadgeTextColor)) { badgeTextColor = a.getColorStateList(R.styleable.SublimeNavigationView_snvBadgeTextColor); } try { // Catch the RuntimeException thrown if // the Typeface filename is incorrect if (a.hasValue(R.styleable.SublimeNavigationView_snvItemTypefaceFilename)) { String itemTypefaceFilename = a .getString(R.styleable.SublimeNavigationView_snvItemTypefaceFilename); if (!TextUtils.isEmpty(itemTypefaceFilename)) { itemTypeface = Typeface.createFromAsset(context.getAssets(), itemTypefaceFilename); } } if (a.hasValue(R.styleable.SublimeNavigationView_snvHintTypefaceFilename)) { String hintTypefaceFilename = a .getString(R.styleable.SublimeNavigationView_snvHintTypefaceFilename); if (!TextUtils.isEmpty(hintTypefaceFilename)) { hintTypeface = Typeface.createFromAsset(context.getAssets(), hintTypefaceFilename); } } if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderItemTypefaceFilename)) { String subheaderItemTypefaceFilename = a .getString(R.styleable.SublimeNavigationView_snvSubheaderItemTypefaceFilename); if (!TextUtils.isEmpty(subheaderItemTypefaceFilename)) { subheaderItemTypeface = Typeface.createFromAsset(context.getAssets(), subheaderItemTypefaceFilename); } } if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderHintTypefaceFilename)) { String subheaderHintTypefaceFilename = a .getString(R.styleable.SublimeNavigationView_snvSubheaderHintTypefaceFilename); if (!TextUtils.isEmpty(subheaderHintTypefaceFilename)) { subheaderHintTypeface = Typeface.createFromAsset(context.getAssets(), subheaderHintTypefaceFilename); } } if (a.hasValue(R.styleable.SublimeNavigationView_snvBadgeTypefaceFilename)) { String badgeTypefaceFilename = a .getString(R.styleable.SublimeNavigationView_snvBadgeTypefaceFilename); if (!TextUtils.isEmpty(badgeTypefaceFilename)) { badgeTypeface = Typeface.createFromAsset(context.getAssets(), badgeTypefaceFilename); } } } catch (RuntimeException re) { Log.e(TAG, "Error loading Typeface from Assets. " + "Confirm that the Typeface filename is correct:\n" + " - filename should include the extension\n" + " - filename is case-sensitive"); } if (a.hasValue(R.styleable.SublimeNavigationView_snvItemTypefaceStyle)) { itemTypefaceStyle = a.getInt(R.styleable.SublimeNavigationView_snvItemTypefaceStyle, Typeface.NORMAL); switch (itemTypefaceStyle) { case 1: itemTypefaceStyle = Typeface.BOLD; break; case 2: itemTypefaceStyle = Typeface.ITALIC; break; case 3: itemTypefaceStyle = Typeface.BOLD_ITALIC; break; default: // case 0: NORMAL itemTypefaceStyle = Typeface.NORMAL; break; } } if (a.hasValue(R.styleable.SublimeNavigationView_snvHintTypefaceStyle)) { hintTypefaceStyle = a.getInt(R.styleable.SublimeNavigationView_snvHintTypefaceStyle, Typeface.NORMAL); switch (hintTypefaceStyle) { case 1: hintTypefaceStyle = Typeface.BOLD; break; case 2: hintTypefaceStyle = Typeface.ITALIC; break; case 3: hintTypefaceStyle = Typeface.BOLD_ITALIC; break; default: // case 0: NORMAL hintTypefaceStyle = Typeface.NORMAL; break; } } if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderItemTypefaceStyle)) { subheaderItemTypefaceStyle = a .getInt(R.styleable.SublimeNavigationView_snvSubheaderItemTypefaceStyle, Typeface.NORMAL); switch (subheaderItemTypefaceStyle) { case 1: subheaderItemTypefaceStyle = Typeface.BOLD; break; case 2: subheaderItemTypefaceStyle = Typeface.ITALIC; break; case 3: subheaderItemTypefaceStyle = Typeface.BOLD_ITALIC; break; default: // case 0: NORMAL subheaderItemTypefaceStyle = Typeface.NORMAL; break; } } if (a.hasValue(R.styleable.SublimeNavigationView_snvSubheaderHintTypefaceStyle)) { subheaderHintTypefaceStyle = a .getInt(R.styleable.SublimeNavigationView_snvSubheaderHintTypefaceStyle, Typeface.NORMAL); switch (subheaderHintTypefaceStyle) { case 1: subheaderHintTypefaceStyle = Typeface.BOLD; break; case 2: subheaderHintTypefaceStyle = Typeface.ITALIC; break; case 3: subheaderHintTypefaceStyle = Typeface.BOLD_ITALIC; break; default: // case 0: NORMAL subheaderHintTypefaceStyle = Typeface.NORMAL; break; } } if (a.hasValue(R.styleable.SublimeNavigationView_snvBadgeTypefaceStyle)) { badgeTypefaceStyle = a.getInt(R.styleable.SublimeNavigationView_snvBadgeTypefaceStyle, Typeface.NORMAL); switch (badgeTypefaceStyle) { case 1: badgeTypefaceStyle = Typeface.BOLD; break; case 2: badgeTypefaceStyle = Typeface.ITALIC; break; case 3: badgeTypefaceStyle = Typeface.BOLD_ITALIC; break; default: // case 0: NORMAL badgeTypefaceStyle = Typeface.NORMAL; break; } } // Item text styling TextViewStyleProfile itemStyleProfile = new TextViewStyleProfile(context, defaultTheme); itemStyleProfile.setTextColor(itemTextColor).setTypeface(itemTypeface) .setTypefaceStyle(itemTypefaceStyle); mThemer.setItemStyleProfile(itemStyleProfile); // Hint text styling TextViewStyleProfile hintStyleProfile = new TextViewStyleProfile(context, defaultTheme); hintStyleProfile.setTextColor(hintTextColor).setTypeface(hintTypeface) .setTypefaceStyle(hintTypefaceStyle); mThemer.setItemHintStyleProfile(hintStyleProfile); // Sub-header item text styling TextViewStyleProfile subheaderItemStyleProfile = new TextViewStyleProfile(context, defaultTheme); subheaderItemStyleProfile.setTextColor(subheaderItemTextColor).setTypeface(subheaderItemTypeface) .setTypefaceStyle(subheaderItemTypefaceStyle); mThemer.setSubheaderStyleProfile(subheaderItemStyleProfile); // Sub-header hint text styling TextViewStyleProfile subheaderHintStyleProfile = new TextViewStyleProfile(context, defaultTheme); subheaderHintStyleProfile.setTextColor(subheaderHintTextColor).setTypeface(subheaderHintTypeface) .setTypefaceStyle(subheaderHintTypefaceStyle); mThemer.setSubheaderHintStyleProfile(subheaderHintStyleProfile); // Badge text styling TextViewStyleProfile badgeStyleProfile = new TextViewStyleProfile(context, defaultTheme); badgeStyleProfile.setTextColor(badgeTextColor).setTypeface(badgeTypeface) .setTypefaceStyle(badgeTypefaceStyle); mThemer.setBadgeStyleProfile(badgeStyleProfile); mThemer.setItemBackground(a.getDrawable(R.styleable.SublimeNavigationView_snvItemBackground)); if (a.hasValue(R.styleable.SublimeNavigationView_snvMenu)) { int menuResId = a.getResourceId(R.styleable.SublimeNavigationView_snvMenu, -1); if (menuResId == -1) { throw new RuntimeException("Passed menuResId was not valid"); } mMenu = new SublimeMenu(menuResId); inflateMenu(menuResId); } mMenu.setCallback(new SublimeMenu.Callback() { public boolean onMenuItemSelected(SublimeMenu menu, SublimeBaseMenuItem item, OnNavigationMenuEventListener.Event event) { return SublimeNavigationView.this.mEventListener != null && SublimeNavigationView.this.mEventListener.onNavigationMenuEvent(event, item); } }); mPresenter = new SublimeMenuPresenter(); applyThemer(); mMenu.setMenuPresenter(getContext(), mPresenter); addView(mPresenter.getMenuView(this)); if (a.hasValue(R.styleable.SublimeNavigationView_snvHeaderLayout)) { inflateHeaderView(a.getResourceId(R.styleable.SublimeNavigationView_snvHeaderLayout, 0)); } } finally { a.recycle(); } // Upon creation, and until initializations are done, // SublimeMenuPresenter blocks all calls for invalidation. // We can now finalize the initialization phase to allow // invalidation of the menu when required. mPresenter.setInitializationDone(); }
From source file:com.grottworkshop.gwsmaterialcalendarview.MaterialCalendarView.java
@SuppressWarnings("deprecation") public MaterialCalendarView(Context context, AttributeSet attrs) { super(context, attrs); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //If we're on good Android versions, turn off clipping for cool effects setClipToPadding(false);// w ww . j av a2 s. co m setClipChildren(false); } else { //Old Android does not like _not_ clipping view pagers, we need to clip setClipChildren(true); setClipToPadding(true); } buttonPast = new DirectionButton(getContext()); title = new TextView(getContext()); buttonFuture = new DirectionButton(getContext()); pager = new ViewPager(getContext()); setupChildren(); title.setOnClickListener(onClickListener); buttonPast.setOnClickListener(onClickListener); buttonFuture.setOnClickListener(onClickListener); titleChanger = new TitleChanger(title); titleChanger.setTitleFormatter(DEFAULT_TITLE_FORMATTER); adapter = new MonthPagerAdapter(); adapter.setTitleFormatter(DEFAULT_TITLE_FORMATTER); pager.setAdapter(adapter); pager.setOnPageChangeListener(pageChangeListener); pager.setPageTransformer(false, new ViewPager.PageTransformer() { @Override public void transformPage(View page, float position) { position = (float) Math.sqrt(1 - Math.abs(position)); page.setAlpha(position); } }); adapter.setCallbacks(monthViewCallbacks); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.MaterialCalendarView, 0, 0); try { int tileSize = a.getDimensionPixelSize(R.styleable.MaterialCalendarView_mcv_tileSize, -1); if (tileSize > 0) { setTileSize(tileSize); } setArrowColor(a.getColor(R.styleable.MaterialCalendarView_mcv_arrowColor, Color.BLACK)); Drawable leftMask = a.getDrawable(R.styleable.MaterialCalendarView_mcv_leftArrowMask); if (leftMask == null) { //TODO: getDrawable depreciated leftMask = getResources().getDrawable(R.drawable.mcv_action_previous); } setLeftArrowMask(leftMask); Drawable rightMask = a.getDrawable(R.styleable.MaterialCalendarView_mcv_rightArrowMask); if (rightMask == null) { //TODO: getDrawable depreciated rightMask = getResources().getDrawable(R.drawable.mcv_action_next); } setRightArrowMask(rightMask); setSelectionColor( a.getColor(R.styleable.MaterialCalendarView_mcv_selectionColor, getThemeAccentColor(context))); CharSequence[] array = a.getTextArray(R.styleable.MaterialCalendarView_mcv_weekDayLabels); if (array != null) { setWeekDayFormatter(new ArrayWeekDayFormatter(array)); } array = a.getTextArray(R.styleable.MaterialCalendarView_mcv_monthLabels); if (array != null) { setTitleFormatter(new MonthArrayTitleFormatter(array)); } setHeaderTextAppearance(a.getResourceId(R.styleable.MaterialCalendarView_mcv_headerTextAppearance, R.style.TextAppearance_MaterialCalendarWidget_Header)); setWeekDayTextAppearance(a.getResourceId(R.styleable.MaterialCalendarView_mcv_weekDayTextAppearance, R.style.TextAppearance_MaterialCalendarWidget_WeekDay)); setDateTextAppearance(a.getResourceId(R.styleable.MaterialCalendarView_mcv_dateTextAppearance, R.style.TextAppearance_MaterialCalendarWidget_Date)); setShowOtherDates(a.getBoolean(R.styleable.MaterialCalendarView_mcv_showOtherDates, false)); int firstDayOfWeek = a.getInt(R.styleable.MaterialCalendarView_mcv_firstDayOfWeek, -1); if (firstDayOfWeek < 0) { firstDayOfWeek = CalendarUtils.getInstance().getFirstDayOfWeek(); } setFirstDayOfWeek(firstDayOfWeek); } catch (Exception e) { e.printStackTrace(); } finally { a.recycle(); } currentMonth = CalendarDay.today(); setCurrentDate(currentMonth); if (isInEditMode()) { removeView(pager); MonthView monthView = new MonthView(context, currentMonth, getFirstDayOfWeek()); monthView.setSelectionColor(getSelectionColor()); monthView.setDateTextAppearance(adapter.getDateTextAppearance()); monthView.setWeekDayTextAppearance(adapter.getWeekDayTextAppearance()); monthView.setShowOtherDates(getShowOtherDates()); addView(monthView, new LayoutParams(MonthView.DEFAULT_MONTH_TILE_HEIGHT)); } }
From source file:com.viewpagerindicator.EgouCirclePageIndicator.java
public EgouCirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//from w w w. jav a2 s. c o m // 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); final float defaultIndicatorPadding = res.getDimension(R.dimen.default_indicator_padding); // Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); 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); mCirclePadding = a.getDimension(R.styleable.CirclePageIndicator_circlePadding, defaultIndicatorPadding); Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); }
From source file:com.jzg.jzgcarsource.view.HorizontalListView.java
/** * Parse the XML configuration for this widget * /*from ww w .j av a2 s. c om*/ * @param context * Context used for extracting attributes * @param attrs * The Attribute Set containing the ColumnView attributes */ private void retrieveXmlConfiguration(Context context, AttributeSet attrs) { if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.HorizontalListView); // Get the provided drawable from the XML final Drawable d = a.getDrawable(R.styleable.HorizontalListView_android_divider); if (d != null) { // If a drawable is provided to use as the divider then use its // intrinsic width for the divider width setDivider(d); } // If a width is explicitly specified then use that width final int dividerWidth = a.getDimensionPixelSize(R.styleable.HorizontalListView_dividerWidth1, 0); if (dividerWidth != 0) { setDividerWidth(dividerWidth); } a.recycle(); } }
From source file:com.viewpagerindicator.CirclePageIndicatorWithoutAnimation.java
public CirclePageIndicatorWithoutAnimation(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;// w ww .jav a2s.c om //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, 0); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); 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); Drawable background = a.getDrawable(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:cn.edu.pkusz.battery.indicator.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs) { super(context, attrs); if (isInEditMode()) return;// ww w. java2 s.c o m //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); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); 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); Drawable background = a.getDrawable(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.gwm.view.ViewPagerIndicator.CirclePageIndicator.java
public CirclePageIndicator(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(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, 0); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); 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); Drawable background = a.getDrawable(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.aibinong.tantan.ui.widget.CircleNoPageIndicator.java
public CircleNoPageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//from ww w.j av a 2 s . c o m //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, 0); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); 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); Drawable background = a.getDrawable(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.common.android.lib.controls.view.indicator.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*from w ww.j av a 2 s . co m*/ //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, 0); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.FILL); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); 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); Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }