List of usage examples for android.content.res TypedArray getInt
public int getInt(@StyleableRes int index, int defValue)
From source file:ar.rulosoft.custompref.SeekBarCustomPreference.java
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomDialogPref, defStyleAttr, defStyleRes);/* w ww . j ava 2 s. co m*/ setMax(a.getInt(R.styleable.CustomDialogPref_val_max, mPreferredMax)); setMin(a.getInt(R.styleable.CustomDialogPref_val_min, mPreferredMin)); a.recycle(); setLayoutResource(R.layout.preference_seekbar_widget_layout); }
From source file:com.stfalcon.chatkit.dialogs.DialogListStyle.java
static DialogListStyle parse(Context context, AttributeSet attrs) { DialogListStyle dialogStyle = new DialogListStyle(context, attrs); TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.DialogsList); //Item background dialogStyle.setDialogItemBackground(typedArray.getColor(R.styleable.DialogsList_dialogItemBackground, ContextCompat.getColor(context, R.color.transparent))); dialogStyle.setDialogUnreadItemBackground( typedArray.getColor(R.styleable.DialogsList_dialogUnreadItemBackground, ContextCompat.getColor(context, R.color.transparent))); //Title text/* w ww.j av a 2 s . co m*/ dialogStyle.setDialogTitleTextColor(typedArray.getColor(R.styleable.DialogsList_dialogTitleTextColor, ContextCompat.getColor(context, R.color.dialog_title_text))); dialogStyle.setDialogTitleTextSize( typedArray.getDimensionPixelSize(R.styleable.DialogsList_dialogTitleTextSize, context.getResources().getDimensionPixelSize(R.dimen.dialog_title_text_size))); dialogStyle.setDialogTitleTextStyle( typedArray.getInt(R.styleable.DialogsList_dialogTitleTextStyle, Typeface.NORMAL)); //Title unread text dialogStyle.setDialogUnreadTitleTextColor( typedArray.getColor(R.styleable.DialogsList_dialogUnreadTitleTextColor, ContextCompat.getColor(context, R.color.dialog_title_text))); dialogStyle.setDialogUnreadTitleTextStyle( typedArray.getInt(R.styleable.DialogsList_dialogUnreadTitleTextStyle, Typeface.NORMAL)); //Message text dialogStyle.setDialogMessageTextColor(typedArray.getColor(R.styleable.DialogsList_dialogMessageTextColor, ContextCompat.getColor(context, R.color.dialog_message_text))); dialogStyle.setDialogMessageTextSize( typedArray.getDimensionPixelSize(R.styleable.DialogsList_dialogMessageTextSize, context.getResources().getDimensionPixelSize(R.dimen.dialog_message_text_size))); dialogStyle.setDialogMessageTextStyle( typedArray.getInt(R.styleable.DialogsList_dialogMessageTextStyle, Typeface.NORMAL)); //Message unread text dialogStyle.setDialogUnreadMessageTextColor( typedArray.getColor(R.styleable.DialogsList_dialogUnreadMessageTextColor, ContextCompat.getColor(context, R.color.dialog_message_text))); dialogStyle.setDialogUnreadMessageTextStyle( typedArray.getInt(R.styleable.DialogsList_dialogUnreadMessageTextStyle, Typeface.NORMAL)); //Date text dialogStyle.setDialogDateColor(typedArray.getColor(R.styleable.DialogsList_dialogDateColor, ContextCompat.getColor(context, R.color.dialog_date_text))); dialogStyle.setDialogDateSize(typedArray.getDimensionPixelSize(R.styleable.DialogsList_dialogDateSize, context.getResources().getDimensionPixelSize(R.dimen.dialog_date_text_size))); dialogStyle.setDialogDateStyle(typedArray.getInt(R.styleable.DialogsList_dialogDateStyle, Typeface.NORMAL)); //Date unread text dialogStyle.setDialogUnreadDateColor(typedArray.getColor(R.styleable.DialogsList_dialogUnreadDateColor, ContextCompat.getColor(context, R.color.dialog_date_text))); dialogStyle.setDialogUnreadDateStyle( typedArray.getInt(R.styleable.DialogsList_dialogUnreadDateStyle, Typeface.NORMAL)); //Unread bubble dialogStyle.setDialogUnreadBubbleEnabled( typedArray.getBoolean(R.styleable.DialogsList_dialogUnreadBubbleEnabled, true)); dialogStyle.setDialogUnreadBubbleBackgroundColor( typedArray.getColor(R.styleable.DialogsList_dialogUnreadBubbleBackgroundColor, ContextCompat.getColor(context, R.color.dialog_unread_bubble))); //Unread bubble text dialogStyle.setDialogUnreadBubbleTextColor( typedArray.getColor(R.styleable.DialogsList_dialogUnreadBubbleTextColor, ContextCompat.getColor(context, R.color.dialog_unread_text))); dialogStyle.setDialogUnreadBubbleTextSize( typedArray.getDimensionPixelSize(R.styleable.DialogsList_dialogUnreadBubbleTextSize, context.getResources().getDimensionPixelSize(R.dimen.dialog_unread_bubble_text_size))); dialogStyle.setDialogUnreadBubbleTextStyle( typedArray.getInt(R.styleable.DialogsList_dialogUnreadBubbleTextStyle, Typeface.NORMAL)); //Avatar dialogStyle.setDialogAvatarWidth(typedArray.getDimensionPixelSize(R.styleable.DialogsList_dialogAvatarWidth, context.getResources().getDimensionPixelSize(R.dimen.dialog_avatar_width))); dialogStyle .setDialogAvatarHeight(typedArray.getDimensionPixelSize(R.styleable.DialogsList_dialogAvatarHeight, context.getResources().getDimensionPixelSize(R.dimen.dialog_avatar_height))); //Last message avatar dialogStyle.setDialogMessageAvatarEnabled( typedArray.getBoolean(R.styleable.DialogsList_dialogMessageAvatarEnabled, true)); dialogStyle.setDialogMessageAvatarWidth( typedArray.getDimensionPixelSize(R.styleable.DialogsList_dialogMessageAvatarWidth, context.getResources().getDimensionPixelSize(R.dimen.dialog_last_message_avatar_width))); dialogStyle.setDialogMessageAvatarHeight( typedArray.getDimensionPixelSize(R.styleable.DialogsList_dialogMessageAvatarHeight, context.getResources().getDimensionPixelSize(R.dimen.dialog_last_message_avatar_height))); //Divider dialogStyle .setDialogDividerEnabled(typedArray.getBoolean(R.styleable.DialogsList_dialogDividerEnabled, true)); dialogStyle.setDialogDividerColor(typedArray.getColor(R.styleable.DialogsList_dialogDividerColor, ContextCompat.getColor(context, R.color.dialog_divider))); dialogStyle.setDialogDividerLeftPadding( typedArray.getDimensionPixelSize(R.styleable.DialogsList_dialogDividerLeftPadding, context.getResources().getDimensionPixelSize(R.dimen.dialog_divider_margin_left))); dialogStyle.setDialogDividerRightPadding( typedArray.getDimensionPixelSize(R.styleable.DialogsList_dialogDividerRightPadding, context.getResources().getDimensionPixelSize(R.dimen.dialog_divider_margin_right))); typedArray.recycle(); return dialogStyle; }
From source file:com.qs.qswlw.view.Mypager.UltraViewPager.java
private void initView(Context context, AttributeSet attrs) { TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.UltraViewPager); setAutoScroll(ta.getInt(R.styleable.UltraViewPager_upv_autoscroll, 0)); setInfiniteLoop(ta.getBoolean(R.styleable.UltraViewPager_upv_infiniteloop, false)); setRatio(ta.getFloat(R.styleable.UltraViewPager_upv_ratio, Float.NaN)); setScrollMode(ScrollMode.getScrollMode(ta.getInt(R.styleable.UltraViewPager_upv_scrollmode, 0))); disableScrollDirection(/*from w w w .java2 s. c o m*/ ScrollDirection.getScrollDirection(ta.getInt(R.styleable.UltraViewPager_upv_disablescroll, 0))); setMultiScreen(ta.getFloat(R.styleable.UltraViewPager_upv_multiscreen, 1f)); setAutoMeasureHeight(ta.getBoolean(R.styleable.UltraViewPager_upv_automeasure, false)); setItemRatio(ta.getFloat(R.styleable.UltraViewPager_upv_itemratio, Float.NaN)); ta.recycle(); }
From source file:com.donsen.svg.ui.common.AnimatedSvgView.java
@SuppressWarnings("NewApi") private void init(Context context, AttributeSet attrs) { mFillPaint = new Paint(); mFillPaint.setAntiAlias(true);//from www. j a va2 s . com mFillPaint.setStyle(Paint.Style.FILL); mMarkerLength = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, MARKER_LENGTH_DIP, getResources().getDisplayMetrics()); mTraceColors = new int[1]; mTraceColors[0] = Color.BLACK; mTraceResidueColors = new int[1]; mTraceResidueColors[0] = Color.argb(50, 0, 0, 0); if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AnimatedSvgView); mViewportWidth = a.getInt(R.styleable.AnimatedSvgView_svgImageSizeX, 433); mRatioSizingInfo.aspectRatioWidth = a.getInt(R.styleable.AnimatedSvgView_svgImageSizeX, 433); mViewportHeight = a.getInt(R.styleable.AnimatedSvgView_svgImageSizeY, 433); mRatioSizingInfo.aspectRatioHeight = a.getInt(R.styleable.AnimatedSvgView_svgImageSizeY, 433); mTraceTime = a.getInt(R.styleable.AnimatedSvgView_svgTraceTime, 2000); mTraceTimePerGlyph = a.getInt(R.styleable.AnimatedSvgView_svgTraceTimePerGlyph, 1000); mFillStart = a.getInt(R.styleable.AnimatedSvgView_svgFillStart, 1200); mFillTime = a.getInt(R.styleable.AnimatedSvgView_svgFillTime, 1000); a.recycle(); mViewport = new PointF(mViewportWidth, mViewportHeight); } // See https://github.com/romainguy/road-trip/blob/master/application/src/main/java/org/curiouscreature/android/roadtrip/IntroView.java // Note: using a software layer here is an optimization. This view works with // hardware accelerated rendering but every time a path is modified (when the // dash path effect is modified), the graphics pipeline will rasterize the path // again in a new texture. Since we are dealing with dozens of paths, it is much // more efficient to rasterize the entire view into a single re-usable texture // instead. Ideally this should be toggled using a heuristic based on the number // and or dimensions of paths to render. // Note that PathDashPathEffects can lead to clipping issues with hardware rendering. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { setLayerType(LAYER_TYPE_SOFTWARE, null); } }
From source file:com.fruit.widget.SlideSwitch.java
public SlideSwitch(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); listener = null;/*from ww w . j av a 2 s .co m*/ paint = new Paint(); paint.setAntiAlias(true); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.slideswitch); color_theme = a.getColor(R.styleable.slideswitch_themeColor, DEFAULT_COLOR_THEME); isOpen = a.getBoolean(R.styleable.slideswitch_isOpen, false); shape = a.getInt(R.styleable.slideswitch_shape, SHAPE_RECT); duration = a.getInt(R.styleable.slideswitch_duration, DURATION); a.recycle(); }
From source file:com.example.administrator.iclub21.view.SlideSwitch.java
public SlideSwitch(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); listener = null;/*from ww w . j a v a 2s .c om*/ paint = new Paint(); paint.setAntiAlias(true); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.slideswitch); color_theme = a.getColor(R.styleable.slideswitch_themeColor, DEFAULT_COLOR_THEME); isOpen = a.getBoolean(R.styleable.slideswitch_isOpen, false); shape = a.getInt(R.styleable.slideswitch_shape, SHAPE_RECT); a.recycle(); }
From source file:com.github.fountaingeyser.typefacecompat.FactoryTypefaceCompat.java
@Override public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { View result = null;//from w w w . j a v a 2s .co m // Allow base factory to try and create a view first if (mBaseFactory != null) { result = mBaseFactory.onCreateView(parent, name, context, attrs); } if (result instanceof TextView) { TextView textView = (TextView) result; String fontFamily = null; int style = 0; Resources.Theme theme = context.getTheme(); TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.TextViewAppearance, 0, 0); TypedArray appearance = null; int ap = a.getResourceId(R.styleable.TextViewAppearance_android_textAppearance, -1); a.recycle(); if (ap != -1) { appearance = theme.obtainStyledAttributes(ap, R.styleable.TextAppearance); } if (appearance != null) { fontFamily = appearance.getString(R.styleable.TextAppearance_android_fontFamily); style = appearance.getInt(R.styleable.TextAppearance_android_textStyle, 0); appearance.recycle(); } a = theme.obtainStyledAttributes(attrs, R.styleable.TextAppearance, 0, 0); if (a.hasValue(R.styleable.TextAppearance_android_fontFamily)) { fontFamily = a.getString(R.styleable.TextAppearance_android_fontFamily); style = a.getInt(R.styleable.TextAppearance_android_textStyle, 0); } a.recycle(); if (fontFamily != null && TypefaceCompat.isSupported(fontFamily)) { Typeface tf = TypefaceCompat.create(textView.getContext(), fontFamily, style); if (tf != null) { textView.setTypeface(tf); } } } return result; }
From source file:arun.com.chromer.settings.widgets.AppPreferenceCardView.java
private void init(AttributeSet attrs, int defStyle) { // Load attributes final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.AppPreferenceCardView, defStyle, 0);/* w ww . j av a 2 s.c o m*/ if (!a.hasValue(R.styleable.AppPreferenceCardView_preferenceType)) { throw new IllegalArgumentException("Must specify app:preferenceType in xml"); } preferenceType = a.getInt(R.styleable.AppPreferenceCardView_preferenceType, 0); setInitialValues(); a.recycle(); addView(LayoutInflater.from(getContext()).inflate(R.layout.widget_app_preference_cardview_content, this, false)); unbinder = ButterKnife.bind(this); }
From source file:com.github.andrewlord1990.materialandroid.component.grid.GridItemView.java
private void loadVariant(TypedArray typedAttrs) { @GridItemVariant/*from w w w .ja v a 2s .c o m*/ int variant = typedAttrs.getInt(R.styleable.MDGridItemView_md_grid_item_variant, VARIANT_ONE_LINE_TEXT); setVariant(variant); }
From source file:com.arksh.summer.ui.zone.widget.ExpandableTextView.java
/** * ?/*from w ww. ja v a2 s . co m*/ * @param attrs */ private void init(AttributeSet attrs) { mCollapsedStatus = new SparseBooleanArray(); TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ExpandableTextView); mMaxCollapsedLines = typedArray.getInt(R.styleable.ExpandableTextView_maxCollapsedLines, MAX_COLLAPSED_LINES); mAnimationDuration = typedArray.getInt(R.styleable.ExpandableTextView_animDuration, DEFAULT_ANIM_DURATION); mExpandDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_expandDrawable); mCollapseDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_collapseDrawable); textCollapse = typedArray.getString(R.styleable.ExpandableTextView_textCollapse); textExpand = typedArray.getString(R.styleable.ExpandableTextView_textExpand); showExpandCollapseDrawable = typedArray .getBoolean(R.styleable.ExpandableTextView_showExpandCollapseDrawable, true); if (showExpandCollapseDrawable) { if (mExpandDrawable == null) { mExpandDrawable = ContextCompat.getDrawable(getContext(), R.drawable.icon_green_arrow_down); } if (mCollapseDrawable == null) { mCollapseDrawable = ContextCompat.getDrawable(getContext(), R.drawable.icon_green_arrow_up); } } if (TextUtils.isEmpty(textCollapse)) { textCollapse = getContext().getString(R.string.shink); } if (TextUtils.isEmpty(textExpand)) { textExpand = getContext().getString(R.string.expand); } contentTextColor = typedArray.getColor(R.styleable.ExpandableTextView_contentTextColor, ContextCompat.getColor(getContext(), R.color.light_gray)); contentTextSize = typedArray.getDimension(R.styleable.ExpandableTextView_contentTextSize, DisplayUtil.sp2px(14)); collapseExpandTextColor = typedArray.getColor(R.styleable.ExpandableTextView_collapseExpandTextColor, ContextCompat.getColor(getContext(), R.color.main_color)); collapseExpandTextSize = typedArray.getDimension(R.styleable.ExpandableTextView_collapseExpandTextSize, DisplayUtil.sp2px(14)); grarity = typedArray.getInt(R.styleable.ExpandableTextView_collapseExpandGrarity, Gravity.LEFT); typedArray.recycle(); // enforces vertical orientation setOrientation(LinearLayout.VERTICAL); // default visibility is gone setVisibility(GONE); }