List of usage examples for android.content.res TypedArray getColorStateList
@Nullable public ColorStateList getColorStateList(@StyleableRes int index)
From source file:android.support.v7.internal.widget.ThemeUtils.java
static ColorStateList getThemeAttrColorStateList(Context context, int attr) { TEMP_ARRAY[0] = attr;/*from w ww . j a va 2s .c o m*/ TypedArray a = context.obtainStyledAttributes(null, TEMP_ARRAY); try { return a.getColorStateList(0); } finally { a.recycle(); } }
From source file:android.support.v7ox.widget.ThemeUtils.java
public static ColorStateList getThemeAttrColorStateList(Context context, int attr) { TEMP_ARRAY[0] = attr;/*from w w w . ja v a 2s . c o m*/ TypedArray a = context.obtainStyledAttributes(null, TEMP_ARRAY); try { return a.getColorStateList(0); } finally { a.recycle(); } }
From source file:com.tr4android.support.extension.picker.PickerThemeUtils.java
public static void setNavButtonDrawable(Context context, ImageButton left, ImageButton right, int monthTextAppearanceResId) { // Retrieve the previous and next drawables AppCompatDrawableManager dm = AppCompatDrawableManager.get(); Drawable prevDrawable = dm.getDrawable(context, R.drawable.ic_chevron_left_black_24dp); Drawable nextDrawable = dm.getDrawable(context, R.drawable.ic_chevron_right_black_24dp); // Proxy the month text color into the previous and next drawables. final TypedArray ta = context.obtainStyledAttributes(null, new int[] { android.R.attr.textColor }, 0, monthTextAppearanceResId);/*from www .j av a2s . c om*/ final ColorStateList monthColor = ta.getColorStateList(0); if (monthColor != null) { DrawableCompat.setTint(DrawableCompat.wrap(prevDrawable), monthColor.getDefaultColor()); DrawableCompat.setTint(DrawableCompat.wrap(nextDrawable), monthColor.getDefaultColor()); } ta.recycle(); // Set the previous and next drawables left.setImageDrawable(prevDrawable); right.setImageDrawable(nextDrawable); }
From source file:org.solovyev.android.widget.menu.CustomPopupMenuHelper.java
@Nullable static ColorStateList getTintColorStateList(Context context) { final TypedArray a = context.obtainStyledAttributes(null, COLOR_ATTRS); try {/*w w w . jav a 2s. co m*/ return a.getColorStateList(0); } finally { a.recycle(); } }
From source file:com.bilibili.magicasakura.utils.ThemeUtils.java
public static ColorStateList getThemeAttrColorStateList(Context context, @AttrRes int attr) { TEMP_ARRAY[0] = attr;// w ww. j a va 2s . c o m TypedArray a = context.obtainStyledAttributes(null, TEMP_ARRAY); try { return a.getColorStateList(0); } finally { a.recycle(); } }
From source file:de.mrapp.android.util.ThemeUtil.java
/** * Obtains the color state list, which corresponds to a specific resource id, from a specific * theme. If the given resource id is invalid, a {@link NotFoundException} will be thrown. * * @param context/*from w w w . ja v a 2 s .c o m*/ * The context, which should be used, as an instance of the class {@link Context}. The * context may not be null * @param themeResourceId * The resource id of the theme, the attribute should be obtained from, as an {@link * Integer} value or -1, if the attribute should be obtained from the given context's * theme * @param resourceId * The resource id of the attribute, which should be obtained, as an {@link Integer} * value. The resource id must corresponds to a valid theme attribute * @return The color state list, which has been obtained, as an instance of the class {@link * ColorStateList} */ public static ColorStateList getColorStateList(@NonNull final Context context, @StyleRes final int themeResourceId, @AttrRes final int resourceId) { TypedArray typedArray = null; try { typedArray = obtainStyledAttributes(context, themeResourceId, resourceId); ColorStateList colorStateList = typedArray.getColorStateList(0); if (colorStateList == null) { throw new NotFoundException("Resource ID #0x" + Integer.toHexString(resourceId) + " is not valid"); } return colorStateList; } finally { if (typedArray != null) { typedArray.recycle(); } } }
From source file:com.google.samples.apps.iosched.ui.widget.NavDrawerItemView.java
public NavDrawerItemView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(HORIZONTAL);//from w w w . j a v a 2 s.co m LayoutInflater.from(context).inflate(R.layout.navdrawer_item_view, this, true); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NavDrawerItemView); if (a.hasValue(R.styleable.NavDrawerItemView_iconTints)) { mIconTints = a.getColorStateList(R.styleable.NavDrawerItemView_iconTints); } }
From source file:org.wso2.iot.nfcprovisioning.uielements.TextInputLayoutWithHelpText.java
public TextInputLayoutWithHelpText(Context context, AttributeSet attrs) { super(context, attrs); final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TextInputLayoutWithHelpText, 0, 0);// w w w . j a v a 2 s .c o m try { mHelperTextColor = a.getColorStateList(R.styleable.TextInputLayoutWithHelpText_helperTextColor); mHelperText = a.getText(R.styleable.TextInputLayoutWithHelpText_helperText); } finally { a.recycle(); } }
From source file:com.orangemoo.com.beta.widget.ViewPagerTabs.java
public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);/* ww w . j a v a 2s. c o m*/ mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); mTextSize = a.getDimensionPixelSize(0, 0); mTextStyle = a.getInt(1, 0); mTextColor = a.getColorStateList(2); mTextAllCaps = a.getBoolean(3, false); mTabStrip = new ViewPagerTabStrip(context); addView(mTabStrip, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); a.recycle(); }
From source file:com.cyanogenmod.eleven.widgets.ViewPagerTabs.java
public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);//from ww w .j a v a2 s .co m mSidePadding = (int) (getResources().getDisplayMetrics().density * TAB_SIDE_PADDING_IN_DPS); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); mTextSize = a.getDimensionPixelSize(0, 0); mTextStyle = a.getInt(1, 0); mTextColor = a.getColorStateList(2); mTextAllCaps = a.getBoolean(3, false); mTabStrip = new ViewPagerTabStrip(context); addView(mTabStrip, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); a.recycle(); // enable shadow casting from view bounds setOutlineProvider(VIEW_BOUNDS_OUTLINE_PROVIDER); }