Java Code Examples for de.mrapp.android.util.ThemeUtil#getColorStateList()
The following examples show how to use
de.mrapp.android.util.ThemeUtil#getColorStateList() .
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: ThemeHelper.java From ChromeLikeTabSwitcher with Apache License 2.0 | 6 votes |
/** * Returns the color state list, which corresponds to a specific theme attribute, regarding the * theme, which is used when using a specific layout. * * @param layout * The layout as a value of the enum {@link Layout}. The layout may not be null * @param resourceId * The resource id of the theme attribute, the color state list should be obtained from, * as an {@link Integer} value. The resource id must correspond to a valid theme * attribute * @return The color state list, which has been obtained, as an instance of the class {@link * ColorStateList} */ public ColorStateList getColorStateList(@NonNull final Layout layout, @AttrRes final int resourceId) { try { return ThemeUtil.getColorStateList(context, resourceId); } catch (NotFoundException e1) { int themeResourceId = getThemeResourceId(layout); try { return ThemeUtil.getColorStateList(context, themeResourceId, resourceId); } catch (NotFoundException e) { themeResourceId = obtainThemeFromThemeAttributes(layout, themeResourceId); return ThemeUtil.getColorStateList(context, themeResourceId, resourceId); } } }
Example 2
Source File: AbstractListDialogBuilder.java From AndroidMaterialDialog with Apache License 2.0 | 5 votes |
/** * Obtains the item color from a specific theme. * * @param themeResourceId * The resource id of the theme, the item color should be obtained from, as an {@link * Integer} value */ private void obtainItemColor(@StyleRes final int themeResourceId) { TypedArray typedArray = getContext().getTheme() .obtainStyledAttributes(themeResourceId, new int[]{R.attr.materialDialogItemColor}); ColorStateList colorStateList = typedArray.getColorStateList(0); if (colorStateList == null) { colorStateList = ThemeUtil.getColorStateList(getContext(), themeResourceId, android.R.attr.textColorSecondary); } setItemColor(colorStateList); }