List of usage examples for android.content.res TypedArray getDrawable
@Nullable public Drawable getDrawable(@StyleableRes int index)
From source file:com.futureinst.viewpagerindicator.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*from w w w.jav a2s. co m*/ //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res.getColor(com.futureinst.R.color.default_circle_indicator_page_color); final int defaultFillColor = res.getColor(com.futureinst.R.color.default_circle_indicator_fill_color); final int defaultOrientation = res .getInteger(com.futureinst.R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = res.getColor(com.futureinst.R.color.default_circle_indicator_stroke_color); final float defaultStrokeWidth = res .getDimension(com.futureinst.R.dimen.default_circle_indicator_stroke_width); final float defaultRadius = res.getDimension(com.futureinst.R.dimen.default_circle_indicator_radius); final boolean defaultCentered = res.getBoolean(com.futureinst.R.bool.default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(com.futureinst.R.bool.default_circle_indicator_snap); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, com.futureinst.R.styleable.CirclePageIndicator, defStyle, 0); mCentered = a.getBoolean(com.futureinst.R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(com.futureinst.R.styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill .setColor(a.getColor(com.futureinst.R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor( a.getColor(com.futureinst.R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke.setStrokeWidth( a.getDimension(com.futureinst.R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor(a.getColor(com.futureinst.R.styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(com.futureinst.R.styleable.CirclePageIndicator_radius, defaultRadius); mSnap = a.getBoolean(com.futureinst.R.styleable.CirclePageIndicator_snap, defaultSnap); Drawable background = a.getDrawable(com.futureinst.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.ecom.consumer.customviews.HorizontalListView.java
/** * Parse the XML configuration for this widget * //from w w w .j a va 2s.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_dividerWidth, 0); if (dividerWidth != 0) { setDividerWidth(dividerWidth); } final boolean autoScroll = a.getBoolean(R.styleable.HorizontalListView_autoRun, false); setAutoScrollEnabled(autoScroll); a.recycle(); } }
From source file:com.simplealertdialog.SimpleAlertDialog.java
private void obtainStyles() { TypedArray a = getContext().getTheme().obtainStyledAttributes(null, R.styleable.SimpleAlertDialogStyle, R.attr.simpleAlertDialogStyle, R.style.Theme_SimpleAlertDialog); mListChoiceIndicatorSingle = a//from w ww. ja v a 2 s. c om .getResourceId(R.styleable.SimpleAlertDialogStyle_sadListChoiceIndicatorSingle, 0); mTitleTextStyle = a.getResourceId(R.styleable.SimpleAlertDialogStyle_sadTitleTextStyle, 0); mMessageTextStyle = a.getResourceId(R.styleable.SimpleAlertDialogStyle_sadMessageTextStyle, 0); mButtonTextStyle = a.getResourceId(R.styleable.SimpleAlertDialogStyle_sadButtonTextStyle, 0); mListItemTextStyle = a.getResourceId(R.styleable.SimpleAlertDialogStyle_sadListItemTextStyle, 0); mListSelectorBackground = a.getDrawable(R.styleable.SimpleAlertDialogStyle_sadListSelectorBackground); mTitleSeparatorBackground = a.getDrawable(R.styleable.SimpleAlertDialogStyle_sadTitleSeparatorBackground); mTitleSeparatorHeight = a.getLayoutDimension(R.styleable.SimpleAlertDialogStyle_sadTitleSeparatorHeight, getContext().getResources().getDimensionPixelSize(R.dimen.sad__dialog_title_separator_height)); mButtonTopDividerBackground = a .getDrawable(R.styleable.SimpleAlertDialogStyle_sadButtonTopDividerBackground); mButtonVerticalDividerBackground = a .getDrawable(R.styleable.SimpleAlertDialogStyle_sadButtonVerticalDividerBackground); mBackgroundFull = a.getDrawable(R.styleable.SimpleAlertDialogStyle_sadBackgroundFull); mBackgroundTop = a.getDrawable(R.styleable.SimpleAlertDialogStyle_sadBackgroundTop); mBackgroundMiddle = a.getDrawable(R.styleable.SimpleAlertDialogStyle_sadBackgroundMiddle); mBackgroundBottom = a.getDrawable(R.styleable.SimpleAlertDialogStyle_sadBackgroundBottom); a.recycle(); }
From source file:am.widget.indicatortabstrip.IndicatorTabStrip.java
public IndicatorTabStrip(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setItemClickable(true);/* www . ja v a 2 s. c o m*/ setClickSmoothScroll(true); final float density = getResources().getDisplayMetrics().density; mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); mTextPaint.setTextAlign(Align.CENTER); if (Build.VERSION.SDK_INT > 4) { updateTextPaintDensity(); } mTagLocation = new TagLocation(TagLocation.LOCATION_EDGE); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); int n = a.getIndexCount(); int textSize = (int) (DEFAULT_TEXT_SIZE * density); ColorStateList textColors = null; Drawable divider = null; for (int i = 0; i < n; i++) { int attr = a.getIndex(i); switch (attr) { case 0: textSize = a.getDimensionPixelSize(attr, textSize); break; case 1: textColors = a.getColorStateList(attr); break; case 2: divider = a.getDrawable(attr); break; } } a.recycle(); float scale = 1; Drawable itemBackground = null; ColorStateList gradient = null; Drawable indicator = null; int indicatorWidthMode = INDICATOR_WIDTH_MODE_SET; int indicatorPadding = 0; int indicatorWidth = INDICATOR_WIDTH_BY_DRAWABLE; int indicatorHeight = INDICATOR_HEIGHT_BY_DRAWABLE; Drawable interval = null; int minItemWidth = (int) (DEFAULT_ITEM_WIDTH * density); int minItemHeight = (int) (DEFAULT_ITEM_HEIGHT * density); int tagTextSize = (int) (DEFAULT_TAG_TEXT_SIZE * density); int tagTextColor = DEFAULT_TAG_TEXT_COLOR; Drawable tagBackground = getDefaultTagBackground(); int tagMinSizeMode = TAG_MIN_SIZE_MODE_HAS_TEXT; int tagMinWidth = (int) (DEFAULT_TAG_MIN_SIZE * density); int tagMinHeight = (int) (DEFAULT_TAG_MIN_SIZE * density); int tagPaddingLeft = 0; int tagPaddingTop = 0; int tagPaddingRight = 0; int tagPaddingBottom = 0; int tagMarginLeft = 0; int tagMarginTop = 0; int tagMarginRight = 0; int tagMarginBottom = 0; TypedArray custom = context.obtainStyledAttributes(attrs, R.styleable.IndicatorTabStrip); textSize = custom.getDimensionPixelSize(R.styleable.IndicatorTabStrip_ttsTextSize, textSize); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsTextColor)) textColors = custom.getColorStateList(R.styleable.IndicatorTabStrip_ttsTextColor); scale = custom.getFloat(R.styleable.IndicatorTabStrip_ttsTextScale, scale); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsBackground)) itemBackground = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsBackground); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsGradient)) gradient = custom.getColorStateList(R.styleable.IndicatorTabStrip_ttsGradient); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsDivider)) divider = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsDivider); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsIndicator)) indicator = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsIndicator); indicatorWidthMode = custom.getInt(R.styleable.IndicatorTabStrip_ttsIndicatorWidthMode, indicatorWidthMode); indicatorPadding = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsIndicatorPadding, indicatorPadding); indicatorWidth = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsIndicatorWidth, indicatorWidth); indicatorHeight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsIndicatorHeight, indicatorHeight); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsInterval)) interval = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsInterval); minItemWidth = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsMinItemWidth, minItemWidth); minItemHeight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsMinItemHeight, minItemHeight); tagTextSize = custom.getDimensionPixelSize(R.styleable.IndicatorTabStrip_ttsTagTextSize, tagTextSize); tagTextColor = custom.getColor(R.styleable.IndicatorTabStrip_ttsTagTextColor, tagTextColor); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsTagBackground)) tagBackground = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsTagBackground); tagMinSizeMode = custom.getInt(R.styleable.IndicatorTabStrip_ttsTagMinSizeMode, tagMinSizeMode); tagMinWidth = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMinWidth, tagMinWidth); tagMinHeight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMinHeight, tagMinHeight); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsTagPadding)) { final int padding = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPadding, 0); tagPaddingLeft = padding; tagPaddingTop = padding; tagPaddingRight = padding; tagPaddingBottom = padding; } tagPaddingLeft = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPaddingLeft, tagPaddingLeft); tagPaddingTop = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPaddingTop, tagPaddingTop); tagPaddingRight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPaddingRight, tagPaddingRight); tagPaddingBottom = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPaddingBottom, tagPaddingBottom); if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsTagMargin)) { final int margin = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMargin, 0); tagMarginLeft = margin; tagMarginTop = margin; tagMarginRight = margin; tagMarginBottom = margin; } tagMarginLeft = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMarginLeft, tagMarginLeft); tagMarginTop = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMarginTop, tagMarginTop); tagMarginRight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMarginRight, tagMarginRight); tagMarginBottom = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMarginBottom, tagMarginBottom); custom.recycle(); setTextSize(textSize); if (textColors != null) { setTextColor(textColors); } else { setTextColor(DEFAULT_TEXT_COLOR); } setTextScale(scale); setItemBackground(itemBackground); setGradient(gradient); setDivider(divider); setIndicator(indicator); setIndicatorWidthMode(indicatorWidthMode); setIndicatorPadding(indicatorPadding); setIndicatorWidth(indicatorWidth); setIndicatorHeight(indicatorHeight); setInterval(interval); setMinItemWidth(minItemWidth); setMinItemHeight(minItemHeight); setTagTextSize(tagTextSize); setTagTextColor(tagTextColor); setTagBackground(tagBackground); setTagMinSizeMode(tagMinSizeMode); setTagMinWidth(tagMinWidth); setTagMinHeight(tagMinHeight); setTagPadding(tagPaddingLeft, tagPaddingTop, tagPaddingRight, tagPaddingBottom); setTagMargin(tagMarginLeft, tagMarginTop, tagMarginRight, tagMarginBottom); }
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;/* www . j a va2s .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.layer.messenger.makemoji.MakeMojiAtlasComposer.java
private void parseStyle(Context context, AttributeSet attrs, int defStyle) { TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, com.layer.atlas.R.styleable.AtlasMessageComposer, com.layer.atlas.R.attr.AtlasMessageComposer, defStyle);/*w w w . j a v a 2s . com*/ mEnabled = ta.getBoolean(com.layer.atlas.R.styleable.AtlasMessageComposer_android_enabled, true); this.mTextColor = ta.getColor(com.layer.atlas.R.styleable.AtlasMessageComposer_inputTextColor, context.getResources().getColor(com.layer.atlas.R.color.atlas_text_black)); this.mTextSize = ta.getDimensionPixelSize(com.layer.atlas.R.styleable.AtlasMessageComposer_inputTextSize, context.getResources().getDimensionPixelSize(com.layer.atlas.R.dimen.atlas_text_size_input)); this.mTextStyle = ta.getInt(com.layer.atlas.R.styleable.AtlasMessageComposer_inputTextStyle, Typeface.NORMAL); String typeFaceName = ta.getString(com.layer.atlas.R.styleable.AtlasMessageComposer_inputTextTypeface); this.mTypeFace = typeFaceName != null ? Typeface.create(typeFaceName, mTextStyle) : null; this.mUnderlineColor = ta.getColor(com.layer.atlas.R.styleable.AtlasMessageComposer_inputUnderlineColor, context.getResources().getColor(com.layer.atlas.R.color.atlas_color_primary_blue)); this.mCursorColor = ta.getColor(com.layer.atlas.R.styleable.AtlasMessageComposer_inputCursorColor, context.getResources().getColor(com.layer.atlas.R.color.atlas_color_primary_blue)); this.mAttachmentSendersBackground = ta .getDrawable(com.layer.atlas.R.styleable.AtlasMessageComposer_attachmentSendersBackground); ta.recycle(); }
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 .j a v a2 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(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:android.support.v7.internal.widget.ActionBarView.java
public ActionBarView(Context context, AttributeSet attrs) { super(context, attrs); mContext = context;/*from w w w . j a v a 2 s . com*/ // Background is always provided by the container. setBackgroundResource(0); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ActionBar, R.attr.actionBarStyle, 0); ApplicationInfo appInfo = context.getApplicationInfo(); PackageManager pm = context.getPackageManager(); mNavigationMode = a.getInt(R.styleable.ActionBar_navigationMode, ActionBar.NAVIGATION_MODE_STANDARD); mTitle = a.getText(R.styleable.ActionBar_title); mSubtitle = a.getText(R.styleable.ActionBar_subtitle); mLogo = a.getDrawable(R.styleable.ActionBar_logo); if (mLogo == null) { if (Build.VERSION.SDK_INT >= 9) { if (context instanceof Activity) { try { mLogo = pm.getActivityLogo(((Activity) context).getComponentName()); } catch (NameNotFoundException e) { Log.e(TAG, "Activity component name not found!", e); } } if (mLogo == null) { mLogo = appInfo.loadLogo(pm); } } } // TODO(trevorjohns): Should these use the android namespace mIcon = a.getDrawable(R.styleable.ActionBar_icon); if (mIcon == null) { if (context instanceof Activity) { try { mIcon = pm.getActivityIcon(((Activity) context).getComponentName()); } catch (NameNotFoundException e) { Log.e(TAG, "Activity component name not found!", e); } } if (mIcon == null) { mIcon = appInfo.loadIcon(pm); } } final LayoutInflater inflater = LayoutInflater.from(context); final int homeResId = a.getResourceId(R.styleable.ActionBar_homeLayout, R.layout.abc_action_bar_home); mHomeLayout = (HomeView) inflater.inflate(homeResId, this, false); mExpandedHomeLayout = (HomeView) inflater.inflate(homeResId, this, false); mExpandedHomeLayout.setUp(true); mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener); mExpandedHomeLayout.setContentDescription(getResources().getText(R.string.abc_action_bar_up_description)); mTitleStyleRes = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0); mSubtitleStyleRes = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0); mProgressStyle = a.getResourceId(R.styleable.ActionBar_progressBarStyle, 0); mIndeterminateProgressStyle = a.getResourceId(R.styleable.ActionBar_indeterminateProgressStyle, 0); mProgressBarPadding = a.getDimensionPixelOffset(R.styleable.ActionBar_progressBarPadding, 0); mItemPadding = a.getDimensionPixelOffset(R.styleable.ActionBar_itemPadding, 0); setDisplayOptions(a.getInt(R.styleable.ActionBar_displayOptions, DISPLAY_DEFAULT)); final int customNavId = a.getResourceId(R.styleable.ActionBar_customNavigationLayout, 0); if (customNavId != 0) { mCustomNavView = (View) inflater.inflate(customNavId, this, false); mNavigationMode = ActionBar.NAVIGATION_MODE_STANDARD; setDisplayOptions(mDisplayOptions | ActionBar.DISPLAY_SHOW_CUSTOM); } mContentHeight = a.getLayoutDimension(R.styleable.ActionBar_height, 0); a.recycle(); mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle); mHomeLayout.setOnClickListener(mUpClickListener); mHomeLayout.setClickable(true); mHomeLayout.setFocusable(true); }
From source file:com.blue.sky.control.CirclePageIndicator.java
@SuppressWarnings("deprecation") public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//w w w . j a v 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 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 defaultPadding = res.getDimension(R.dimen.default_circle_indicator_padding); defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width); // Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, Styleable.CirclePageIndicator, defStyle, 0); indicateCircleType = a.getInt(Styleable.CirclePageIndicator_unIndicateCircleType, 0); mCentered = a.getBoolean(Styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(Styleable.CirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(Styleable.CirclePageIndicator_pageColor, defaultPageColor)); if (indicateCircleType == 0) { mPaintStroke.setStyle(Style.STROKE); } else if (indicateCircleType == 1) { mPaintStroke.setStyle(Style.FILL); } mPaintStroke.setColor(a.getColor(Styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke.setStrokeWidth(a.getDimension(Styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor(a.getColor(Styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(Styleable.CirclePageIndicator_radius, defaultRadius); padding = a.getDimension(Styleable.CirclePageIndicator_padding, defaultPadding); mSnap = a.getBoolean(Styleable.CirclePageIndicator_snap, defaultSnap); Drawable background = a.getDrawable(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.albedinsky.android.ui.widget.ViewPagerWidget.java
/** * Called from one of constructors of this view to perform its initialization. * <p>//w w w .java 2 s . c o m * Initialization is done via parsing of the specified <var>attrs</var> set and obtaining for * this view specific data from it that can be used to configure this new view instance. The * specified <var>defStyleAttr</var> and <var>defStyleRes</var> are used to obtain default data * from the current theme provided by the specified <var>context</var>. */ private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { this.ensureDecorator(); mDecorator.processAttributes(context, attrs, defStyleAttr, defStyleRes); final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Ui_ViewPager, defStyleAttr, defStyleRes); if (typedArray != null) { final int n = typedArray.getIndexCount(); for (int i = 0; i < n; i++) { final int index = typedArray.getIndex(i); if (index == R.styleable.Ui_ViewPager_android_background) { int resID = typedArray.getResourceId(index, -1); if (resID != -1) { setBackgroundResource(resID); } else { setBackgroundColor(typedArray.getColor(0, Color.TRANSPARENT)); } } else if (index == R.styleable.Ui_ViewPager_uiPageMargin) { setPageMargin(typedArray.getDimensionPixelSize(index, 0)); } else if (index == R.styleable.Ui_ViewPager_uiPageMarginDrawable) { setPageMarginDrawable(typedArray.getDrawable(index)); } else if (index == R.styleable.Ui_ViewPager_uiPageSwipingEnabled) { mDecorator.updatePrivateFlags(PFLAG_PAGE_SWIPING_ENABLED, typedArray.getBoolean(index, true)); } else if (index == R.styleable.Ui_ViewPager_uiPageFlingSwipingEnabled) { mDecorator.updatePrivateFlags(PFLAG_PAGE_FLING_SWIPING_ENABLED, typedArray.getBoolean(index, false)); } else if (index == R.styleable.Ui_ViewPager_uiPageFlingSwipingSensitivity) { this.mPageFlingSwipingSensitivity = Math.max(0, typedArray.getFloat(index, mPageFlingSwipingSensitivity)); } else if (index == R.styleable.Ui_ViewPager_uiCurrentPage) { this.mCurrentPage = typedArray.getInteger(index, 0); } else if (index == R.styleable.Ui_ViewPager_uiOffScreenPageLimit) { setOffscreenPageLimit(typedArray.getInt(index, getOffscreenPageLimit())); } else if (index == R.styleable.Ui_ViewPager_uiPageScrollDuration) { this.mPageScrollDuration = typedArray.getInteger(index, mPageScrollDuration); } else if (index == R.styleable.Ui_ViewPager_uiPageScrollRelativeDurationEnabled) { mDecorator.updatePrivateFlags(PFLAG_PAGE_SCROLL_RELATIVE_DURATION_ENABLED, typedArray.getBoolean(index, false)); } else if (index == R.styleable.Ui_ViewPager_uiPullEnabled) { setPullEnabled(typedArray.getBoolean(index, false)); } } typedArray.recycle(); } // Override default scroller so we can use custom durations for scroll if requested. setScroller(new WidgetScroller(context, SCROLLER_INTERPOLATOR)); }