android.support.annotation.StyleableRes Java Examples
The following examples show how to use
android.support.annotation.StyleableRes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SelectorPre21DrawableCreator.java From BackgroundLibrary with Apache License 2.0 | 6 votes |
private void setSelectorDrawable(StateListDrawable stateListDrawable, @StyleableRes int solidAttr, @StyleableRes int strokeAttr, @AttrRes int functionId) throws Exception { if (typedArray.hasValue(solidAttr) || typedArray.hasValue(strokeAttr)) { GradientDrawable tmpDrawable = DrawableFactory.getDrawable(typedArray); if (typedArray.hasValue(solidAttr)) { tmpDrawable.setColor(typedArray.getColor(solidAttr, 0)); } if (typedArray.hasValue(strokeAttr)) { int strokeWidth = typedArray.getDimensionPixelSize(R.styleable.background_bl_stroke_width, 0); int strokeColor = typedArray.getColor(strokeAttr, 0); float strokeDashWidth = typedArray.getDimension(R.styleable.background_bl_stroke_dashWidth, 0f); float strokeGap = typedArray.getDimension(R.styleable.background_bl_stroke_dashGap, 0f); tmpDrawable.setStroke(strokeWidth, strokeColor, strokeDashWidth, strokeGap); } stateListDrawable.addState(new int[]{functionId}, tmpDrawable); } }
Example #2
Source File: FontViewHelper.java From openwebnet-android with MIT License | 6 votes |
public static void initCustomFont(TextView view, AttributeSet attributeSet, @StyleableRes int[] attrs, int attrIndex) { TypedArray typedArray = view.getContext().getTheme() .obtainStyledAttributes(attributeSet, attrs, 0, 0); try { int fontIndex = typedArray.getInt(attrIndex, DEFAULT_FONT); String fontPath = FONTS.get(fontIndex); if (fontPath != null) { view.setTypeface(Typeface.createFromAsset(view.getContext().getAssets(), fontPath)); } else { throw new IllegalArgumentException("invalid font path"); } } finally { typedArray.recycle(); } }
Example #3
Source File: ThemeUtils.java From More-For-GO with GNU General Public License v3.0 | 6 votes |
@ColorInt private static int[] resolveThemeColors(@NonNull Context context, @AttrRes @StyleableRes int[] attrs, @ColorInt int[] defaultColors) { if (attrs.length != defaultColors.length) throw new IllegalArgumentException("Argument attrs must be the same size as defaultColors"); TypedValue typedValue = new TypedValue(); TypedArray a = context.obtainStyledAttributes(typedValue.data, attrs); for (int i = 0; i < attrs.length; i++) { defaultColors[i] = a.getColor(0, defaultColors[i]); } a.recycle(); return defaultColors; }
Example #4
Source File: AnimationDrawableCreator.java From BackgroundLibrary with Apache License 2.0 | 5 votes |
private void addFrame(@StyleableRes int itemDrawableId, @StyleableRes int itemDurationId){ if(animationTa.hasValue(itemDrawableId)){ Drawable itemDrawable = animationTa.getDrawable(itemDrawableId); if(itemDrawable != null){ if(animationTa.hasValue(itemDurationId)){ drawable.addFrame(itemDrawable, animationTa.getInt(itemDurationId, 0)); }else { drawable.addFrame(itemDrawable, duration); } } } }
Example #5
Source File: TooltipView.java From tooltip-view with MIT License | 5 votes |
private int getDimension(TypedArray a, @StyleableRes int styleableId, @DimenRes int defaultDimension) { int result = a.getDimensionPixelSize(styleableId, NOT_PRESENT); if (result == NOT_PRESENT) { result = getResources().getDimensionPixelSize(defaultDimension); } return result; }
Example #6
Source File: NumberPadTimePickerBottomSheetComponent.java From BottomSheetPickers with Apache License 2.0 | 5 votes |
@NonNull private static int[] resolveColorAttributesFromTheme(Context context, @StyleableRes int[] attrs) { final TypedArray ta = context.obtainStyledAttributes(attrs); final int[] colors = new int[attrs.length]; for (int idxAttr = 0; idxAttr < colors.length; idxAttr++) { colors[idxAttr] = ta.getColor(idxAttr, 0); } ta.recycle(); return colors; }
Example #7
Source File: TypedArrayHelper.java From CameraButton with Apache License 2.0 | 5 votes |
static int getInteger(Context context, TypedArray array, @StyleableRes int attr, @IntegerRes int defaultIntRes) { return array.getInteger( attr, context.getResources().getInteger(defaultIntRes)); }
Example #8
Source File: TypedArrayHelper.java From CameraButton with Apache License 2.0 | 5 votes |
@DrawableRes @Nullable static int[] getDrawableResources(Context context, TypedArray array, @StyleableRes int attr) { int resourceId = array.getResourceId(attr, -1); return resourceId == -1 ? null : context.getResources().getIntArray(resourceId); }
Example #9
Source File: TypedArrayHelper.java From CameraButton with Apache License 2.0 | 5 votes |
@ColorInt static int[] getColors(Context context, TypedArray array, @StyleableRes int attr, @ArrayRes int defaultColorsRes) { return context.getResources().getIntArray( array.getResourceId(attr, defaultColorsRes)); }
Example #10
Source File: TypedArrayHelper.java From CameraButton with Apache License 2.0 | 5 votes |
@ColorInt @SuppressWarnings("deprecation") static int getColor(Context context, TypedArray array, @StyleableRes int attr, @ColorRes int defaultColorRes) { if (Build.VERSION.SDK_INT >= 23) { return array.getColor(attr, context.getColor(defaultColorRes)); } else { return array.getColor(attr, context.getResources().getColor(defaultColorRes)); } }
Example #11
Source File: TypedArrayHelper.java From CameraButton with Apache License 2.0 | 5 votes |
@Px static int getDimension(Context context, TypedArray array, @StyleableRes int attr, @DimenRes int defaultDimenRes) { return array.getDimensionPixelOffset( attr, context.getResources().getDimensionPixelSize(defaultDimenRes)); }
Example #12
Source File: NumberPadTimePickerBottomSheetComponent.java From NumberPadTimePicker with Apache License 2.0 | 5 votes |
@NonNull private static int[] resolveColorAttributesFromTheme(Context context, @StyleableRes int[] attrs) { final TypedArray ta = context.obtainStyledAttributes(attrs); final int[] colors = new int[attrs.length]; for (int idxAttr = 0; idxAttr < colors.length; idxAttr++) { colors[idxAttr] = ta.getColor(idxAttr, 0); } ta.recycle(); return colors; }
Example #13
Source File: TypedArrayUtils.java From letv with Apache License 2.0 | 5 votes |
public static CharSequence[] getTextArray(TypedArray a, @StyleableRes int index, @StyleableRes int fallbackIndex) { CharSequence[] val = a.getTextArray(index); if (val == null) { return a.getTextArray(fallbackIndex); } return val; }
Example #14
Source File: TypedArrayUtils.java From letv with Apache License 2.0 | 5 votes |
public static String getString(TypedArray a, @StyleableRes int index, @StyleableRes int fallbackIndex) { String val = a.getString(index); if (val == null) { return a.getString(fallbackIndex); } return val; }
Example #15
Source File: TypedArrayUtils.java From letv with Apache License 2.0 | 5 votes |
public static Drawable getDrawable(TypedArray a, @StyleableRes int index, @StyleableRes int fallbackIndex) { Drawable val = a.getDrawable(index); if (val == null) { return a.getDrawable(fallbackIndex); } return val; }
Example #16
Source File: StickyScrollPresenter.java From StickyScrollView with MIT License | 5 votes |
public void onGlobalLayoutChange(@StyleableRes int headerRes, @StyleableRes int footerRes){ int headerId = mTypedArrayResourceProvider.getResourceId(headerRes); if(headerId != 0) { mStickyScrollPresentation.initHeaderView(headerId); } int footerId = mTypedArrayResourceProvider.getResourceId(footerRes); if(footerId != 0){ mStickyScrollPresentation.initFooterView(footerId); } mTypedArrayResourceProvider.recycle(); }
Example #17
Source File: ContextUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public static TypedArray obtainStyledAttributes(AttributeSet set, @StyleableRes int[] attrs) { return Base.getContext().obtainStyledAttributes(set, attrs); }
Example #18
Source File: ActivityResourceFinder.java From styT with Apache License 2.0 | 4 votes |
@NonNull @Override public TypedArray obtainStyledAttributes(@StyleRes int resId, @StyleableRes int[] attrs) { return mActivity.obtainStyledAttributes(resId, attrs); }
Example #19
Source File: FlatButton.java From hkm-progress-button with MIT License | 4 votes |
private int getColorXML(@ColorRes int colorResId, @StyleableRes int styleIdColor) { int default_color = getResources().getColor(colorResId); return mAttr.getColor(styleIdColor, default_color); }
Example #20
Source File: ThemeUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public static TypedArray obtainStyledAttributes(@StyleableRes int[] attrs) { return Base.getTheme().obtainStyledAttributes(attrs); }
Example #21
Source File: ThemeUtils.java From More-For-GO with GNU General Public License v3.0 | 4 votes |
@ColorInt private static int resolveThemeColor(@NonNull Context context, @AttrRes @StyleableRes int attr) { return resolveThemeColors(context, new int[]{attr}, new int[]{0})[0]; }
Example #22
Source File: ThemeUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public static TypedArray obtainStyledAttributes(@StyleRes int resid, @StyleableRes int[] attrs) { return Base.getTheme().obtainStyledAttributes(resid, attrs); }
Example #23
Source File: ThemeUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public static TypedArray obtainStyledAttributes(AttributeSet set, @StyleableRes int[] attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) { return Base.getTheme().obtainStyledAttributes(set, attrs, defStyleAttr, defStyleRes); }
Example #24
Source File: ContextUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public static TypedArray obtainStyledAttributes(@StyleableRes int[] attrs) { return Base.getContext().obtainStyledAttributes(attrs); }
Example #25
Source File: ContextUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public static TypedArray obtainStyledAttributes(AttributeSet set, @StyleableRes int[] attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) { return Base.getContext().obtainStyledAttributes(set, attrs, defStyleAttr, defStyleRes); }
Example #26
Source File: TypedArrayUtils.java From letv with Apache License 2.0 | 4 votes |
public static boolean getBoolean(TypedArray a, @StyleableRes int index, @StyleableRes int fallbackIndex, boolean defaultValue) { return a.getBoolean(index, a.getBoolean(fallbackIndex, defaultValue)); }
Example #27
Source File: ContextUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public static TypedArray obtainStyledAttributes(@StyleRes int resid, @StyleableRes int[] attrs) { return Base.getContext().obtainStyledAttributes(resid, attrs); }
Example #28
Source File: IntegerSimpleMenuPreference.java From FontProvider with MIT License | 4 votes |
@SuppressLint("RestrictedApi") private static int[] getIntArray(TypedArray a, @StyleableRes int index, @StyleableRes int fallbackIndex) { int resourceId = TypedArrayUtils.getResourceId(a, index, fallbackIndex, 0); return a.getResources().getIntArray(resourceId); }
Example #29
Source File: ResourceProvider.java From StickyScrollView with MIT License | 4 votes |
public ResourceProvider(Context context, AttributeSet attrs, @StyleableRes int[] styleRes) { mTypeArray = context.obtainStyledAttributes(attrs, styleRes); }
Example #30
Source File: TypedArrayUtils.java From letv with Apache License 2.0 | 4 votes |
@AnyRes public static int getResourceId(TypedArray a, @StyleableRes int index, @StyleableRes int fallbackIndex, @AnyRes int defaultValue) { return a.getResourceId(index, a.getResourceId(fallbackIndex, defaultValue)); }