List of usage examples for android.content.res TypedArray getString
@Nullable public String getString(@StyleableRes int index)
From source file:com.chao.facebookzc.widget.PickerFragment.java
@Override public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) { super.onInflate(activity, attrs, savedInstanceState); TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.com_facebook_picker_fragment); setShowPictures(a.getBoolean(R.styleable.com_facebook_picker_fragment_show_pictures, showPictures)); String extraFieldsString = a.getString(R.styleable.com_facebook_picker_fragment_extra_fields); if (extraFieldsString != null) { String[] strings = extraFieldsString.split(","); setExtraFields(Arrays.asList(strings)); }/*from ww w.j av a 2 s . com*/ showTitleBar = a.getBoolean(R.styleable.com_facebook_picker_fragment_show_title_bar, showTitleBar); titleText = a.getString(R.styleable.com_facebook_picker_fragment_title_text); doneButtonText = a.getString(R.styleable.com_facebook_picker_fragment_done_button_text); titleBarBackground = a.getDrawable(R.styleable.com_facebook_picker_fragment_title_bar_background); doneButtonBackground = a.getDrawable(R.styleable.com_facebook_picker_fragment_done_button_background); a.recycle(); }
From source file:com.example.fansonlib.widget.calendar.CalendarView.java
public CalendarView(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.CalendarView); mCurDayTextColor = array.getColor(R.styleable.CalendarView_current_day_text_color, Color.RED); mSchemeStyle = array.getInt(R.styleable.CalendarView_scheme_theme_style, CalendarCardView.STYLE_STROKE); mSelectThemeStyle = array.getInt(R.styleable.CalendarView_selected_theme_style, CalendarCardView.STYLE_STROKE); mSchemeTextColor = array.getColor(R.styleable.CalendarView_scheme_text_color, Color.RED); mSchemeThemeColor = array.getColor(R.styleable.CalendarView_scheme_theme_color, 0x50CFCFCF); isShowLunar = array.getBoolean(R.styleable.CalendarView_show_lunar, true); mCalendarCardViewClass = array.getString(R.styleable.CalendarView_calendar_card_view); mWeekBackground = array.getColor(R.styleable.CalendarView_week_background, Color.WHITE); mWeekTextColor = array.getColor(R.styleable.CalendarView_week_text_color, Color.BLACK); mSelectedThemeColor = array.getColor(R.styleable.CalendarView_selected_theme_color, 0x50CFCFCF); mSelectedTextColor = array.getColor(R.styleable.CalendarView_selected_text_color, 0xFF111111); mCurrentMonthTextColor = array.getColor(R.styleable.CalendarView_current_month_text_color, 0xFF111111); mOtherMonthTextColor = array.getColor(R.styleable.CalendarView_other_month_text_color, 0xFFe1e1e1); mLunarTextColor = array.getColor(R.styleable.CalendarView_lunar_text_color, Color.GRAY); mMinYear = array.getInt(R.styleable.CalendarView_min_year, 2010); mMaxYear = array.getInt(R.styleable.CalendarView_max_year, 2050); if (mMinYear <= 1900) mMaxYear = 1900;// w w w. j a va2 s. c o m if (mMaxYear >= 2099) mMaxYear = 2099; array.recycle(); init(context); }
From source file:com.journeyapps.barcodescanner.WXViewfinderView.java
public WXViewfinderView(Context context, AttributeSet attrs) { super(context, attrs); // Initialize these once for performance rather than calling them every time in onDraw(). maskPaint = new Paint(Paint.ANTI_ALIAS_FLAG); borderPaint = new Paint(Paint.ANTI_ALIAS_FLAG); cornerPaint = new Paint(Paint.ANTI_ALIAS_FLAG); textPaint = new Paint(Paint.ANTI_ALIAS_FLAG); Resources resources = getResources(); // Get setted attributes on view TypedArray attributes = getContext().obtainStyledAttributes(attrs, R.styleable.zxing_WXViewfinderView); this.maskColor = attributes.getColor(R.styleable.zxing_WXViewfinderView_zxing_mask_color, Color.parseColor("#8c000000")); this.laserColor = attributes.getColor(R.styleable.zxing_WXViewfinderView_zxing_laser_color, Color.parseColor("#d90000")); this.cornerColor = attributes.getColor(R.styleable.zxing_WXViewfinderView_zxing_corner_color, Color.parseColor("#d90000")); this.borderColor = attributes.getColor(R.styleable.zxing_WXViewfinderView_zxing_border_color, Color.parseColor("#dfdfdf")); this.borderWidth = attributes.getDimension(R.styleable.zxing_WXViewfinderView_zxing_border_width, 1); this.cornerWidth = attributes.getDimension(R.styleable.zxing_WXViewfinderView_zxing_corner_width, 3); this.cornerLength = attributes.getDimension(R.styleable.zxing_WXViewfinderView_zxing_corner_length, 12); this.statusText = attributes.getString(R.styleable.zxing_WXViewfinderView_zxing_status_text); if (statusText == null) { statusText = "?????"; }/*from w ww .j ava 2s.c om*/ this.statusTextColor = attributes.getColor(R.styleable.zxing_WXViewfinderView_zxing_status_color, Color.parseColor("#b6b0b0")); this.statusTextPadding = attributes.getDimension(R.styleable.zxing_WXViewfinderView_zxing_status_padding, 32); this.statusTextSize = attributes.getDimensionPixelSize(R.styleable.zxing_WXViewfinderView_zxing_status_size, 24); maskPaint.setStyle(Paint.Style.FILL); maskPaint.setColor(maskColor); borderPaint.setStyle(Paint.Style.STROKE); borderPaint.setStrokeWidth(borderWidth); borderPaint.setColor(borderColor); cornerPaint.setStrokeWidth(cornerWidth); cornerPaint.setColor(cornerColor); cornerPaint.setStyle(Paint.Style.STROKE); textPaint.setTextSize(statusTextSize); textPaint.setColor(statusTextColor); attributes.recycle(); }
From source file:ru.tinkoff.acquiring.sdk.EnterCardFragment.java
@Override public void onAttach(Context context) { super.onAttach(context); TypedArray typedArray = context.getTheme().obtainStyledAttributes(new int[] { R.attr.acqPayAmountPosition, R.attr.acqPayButtonAndIconPosition, R.attr.acqPayWithAmountFormat, R.attr.acqMoneyAmountFormat }); amountPositionMode = typedArray.getInt(AMOUNT_POSITION_INDEX, AMOUNT_POSITION_OVER_FIELDS); buttonAndIconsPositionMode = typedArray.getInt(BUTTON_POSITION_INDEX, BUTTON_UNDER_FIELDS_ICONS_ON_BOTTOM); payAmountFormat = typedArray.getString(PAY_WITH_AMOUNT_FORMAT_INDEX); moneyAmountFormat = typedArray.getString(MONEY_AMOUNT_FORMAT_INDEX); typedArray.recycle();/*w ww . j a va2 s . co m*/ }
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 va 2 s.c om*/ 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:co.ceryle.segmentedbutton.SegmentedButton.java
private void getAttributes(AttributeSet attrs) { TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.SegmentedButton); imageTint = typedArray.getColor(R.styleable.SegmentedButton_sb_imageTint, -1); hasButtonImageTint = typedArray.hasValue(R.styleable.SegmentedButton_sb_imageTint); buttonImageScale = typedArray.getFloat(R.styleable.SegmentedButton_sb_imageScale, 1); selectedImageTint = typedArray.getColor(R.styleable.SegmentedButton_sb_selectedImageTint, 0); hasSelectedImageTint = typedArray.hasValue(R.styleable.SegmentedButton_sb_selectedImageTint); selectedTextColor = typedArray.getColor(R.styleable.SegmentedButton_sb_selectedTextColor, 0); hasTextColorOnSelection = typedArray.hasValue(R.styleable.SegmentedButton_sb_selectedTextColor); rippleColor = typedArray.getColor(R.styleable.SegmentedButton_sb_rippleColor, 0); hasRipple = typedArray.hasValue(R.styleable.SegmentedButton_sb_rippleColor); typeface = typedArray.getString(R.styleable.SegmentedButton_sb_typeface); try {//from w w w .j a va 2 s .c om hasWeight = typedArray.hasValue(R.styleable.SegmentedButton_android_layout_weight); buttonWeight = typedArray.getFloat(R.styleable.SegmentedButton_android_layout_weight, -1); buttonWidth = typedArray.getDimensionPixelSize(R.styleable.SegmentedButton_android_layout_width, 0); hasWidth = typedArray.hasValue(R.styleable.SegmentedButton_android_layout_width); } catch (Exception ex) { Log.d("SegmentedButton", ex.toString()); } typedArray.recycle(); }
From source file:com.wnafee.vector.compat.AnimatedVectorDrawable.java
public void inflate(Context c, Resources res, XmlPullParser parser, AttributeSet attrs, Theme theme) throws XmlPullParserException, IOException { int eventType = parser.getEventType(); float pathErrorScale = 1; while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG) { final String tagName = parser.getName(); if (ANIMATED_VECTOR.equals(tagName)) { final TypedArray a = obtainAttributes(res, theme, attrs, R.styleable.AnimatedVectorDrawable); int drawableRes = a.getResourceId(R.styleable.AnimatedVectorDrawable_android_drawable, 0); if (drawableRes != 0) { VectorDrawable vectorDrawable = (VectorDrawable) VectorDrawable.create(res, drawableRes) .mutate();// w w w .java 2 s. com vectorDrawable.setAllowCaching(false); pathErrorScale = vectorDrawable.getPixelSize(); mAnimatedVectorState.mVectorDrawable = vectorDrawable; } a.recycle(); } else if (TARGET.equals(tagName)) { final TypedArray a = obtainAttributes(res, theme, attrs, R.styleable.AnimatedVectorDrawableTarget); final String target = a.getString(R.styleable.AnimatedVectorDrawableTarget_android_name); int id = a.getResourceId(R.styleable.AnimatedVectorDrawableTarget_android_animation, 0); if (id != 0) { //path animators require separate handling Animator objectAnimator; if (isPath(target)) { objectAnimator = getPathAnimator(c, res, theme, id, pathErrorScale); } else { objectAnimator = AnimatorInflater.loadAnimator(c, id); } setupAnimatorsForTarget(target, objectAnimator); } a.recycle(); } } eventType = parser.next(); } }
From source file:com.roselism.bottomsheet.BottomSheet.java
@SuppressWarnings("WeakerAccess") BottomSheet(Context context, int theme) { super(context, theme); TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.BottomSheet, R.attr.bottomSheetStyle, 0);// w w w.j a v a 2s .c o m mHasContent = builder.hasContent; try { more = a.getDrawable(R.styleable.BottomSheet_bs_moreDrawable); close = a.getDrawable(R.styleable.BottomSheet_bs_closeDrawable); moreText = a.getString(R.styleable.BottomSheet_bs_moreText); collapseListIcons = a.getBoolean(R.styleable.BottomSheet_bs_collapseListIcons, true); mHeaderLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_headerLayout, mHasContent ? R.layout.bs_header_center : R.layout.bs_header); if (theme == R.style.BottomSheet_DialogHorizontalContent) { mListItemLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_listItemLayout, mHasContent ? R.layout.bs_list_entry_hor_two : R.layout.bs_list_entry_hor_one); } else if (theme == R.style.BottomSheet_Dialog) { mListItemLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_listItemLayout, R.layout.bs_list_entry_normal); } else { mListItemLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_listItemLayout, R.layout.bs_list_entry_normal); } mGridItemLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_gridItemLayout, R.layout.bs_grid_entry); } finally { a.recycle(); } // https://github.com/jgilfelt/SystemBarTint/blob/master/library/src/com/readystatesoftware/systembartint/SystemBarTintManager.java if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { helper = new TranslucentHelper(this, context); } }
From source file:com.roselism.bottomsheet.BottomSheet.java
@SuppressWarnings("WeakerAccess") BottomSheet(Context context, int theme, Builder builder) { super(context, theme); TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.BottomSheet, R.attr.bottomSheetStyle, 0);//from w w w .j a v a 2 s . c o m mHasContent = builder.hasContent; try { more = a.getDrawable(R.styleable.BottomSheet_bs_moreDrawable); close = a.getDrawable(R.styleable.BottomSheet_bs_closeDrawable); moreText = a.getString(R.styleable.BottomSheet_bs_moreText); collapseListIcons = a.getBoolean(R.styleable.BottomSheet_bs_collapseListIcons, true); mHeaderLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_headerLayout, mHasContent ? R.layout.bs_header_center : R.layout.bs_header); if (theme == R.style.BottomSheet_DialogHorizontalContent) { mListItemLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_listItemLayout, mHasContent ? R.layout.bs_list_entry_hor_two : R.layout.bs_list_entry_hor_one); } else if (theme == R.style.BottomSheet_Dialog) { mListItemLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_listItemLayout, R.layout.bs_list_entry_normal); } else { mListItemLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_listItemLayout, R.layout.bs_list_entry_normal); } mGridItemLayoutId = a.getResourceId(R.styleable.BottomSheet_bs_gridItemLayout, R.layout.bs_grid_entry); } finally { a.recycle(); } // https://github.com/jgilfelt/SystemBarTint/blob/master/library/src/com/readystatesoftware/systembartint/SystemBarTintManager.java if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { helper = new TranslucentHelper(this, context); } }
From source file:com.todddavies.components.progressbar.ProgressWheel.java
/** * Parse the attributes passed to the view from the XML * * @param a the attributes to parse//from ww w . j a v a 2 s . co m */ private void parseAttributes(TypedArray a) { barWidth = (int) a.getDimension(R.styleable.ProgressWheel_barWidth, barWidth); rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_rimWidth, rimWidth); spinSpeed = (int) a.getDimension(R.styleable.ProgressWheel_spinSpeed, spinSpeed); delayMillis = a.getInteger(R.styleable.ProgressWheel_delayMillis, delayMillis); if (delayMillis < 0) { delayMillis = 0; } barColor = a.getColor(R.styleable.ProgressWheel_barColor, barColor); barLength = (int) a.getDimension(R.styleable.ProgressWheel_barLength, barLength); textSize = (int) a.getDimension(R.styleable.ProgressWheel_textSize, textSize); textColor = (int) a.getColor(R.styleable.ProgressWheel_textColor, textColor); //if the text is empty , so ignore it if (a.hasValue(R.styleable.ProgressWheel_text)) { setText(a.getString(R.styleable.ProgressWheel_text)); } rimColor = (int) a.getColor(R.styleable.ProgressWheel_rimColor, rimColor); circleColor = (int) a.getColor(R.styleable.ProgressWheel_circleColor, circleColor); contourColor = a.getColor(R.styleable.ProgressWheel_contourColor, contourColor); contourSize = a.getDimension(R.styleable.ProgressWheel_contourSize, contourSize); // Recycle a.recycle(); }