本文整理汇总了Java中de.mrapp.android.util.ThemeUtil.getColor方法的典型用法代码示例。如果您正苦于以下问题:Java ThemeUtil.getColor方法的具体用法?Java ThemeUtil.getColor怎么用?Java ThemeUtil.getColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.mrapp.android.util.ThemeUtil
的用法示例。
在下文中一共展示了ThemeUtil.getColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TabSwitcherDrawable
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* Creates a new drawable, which allows to display the number of tabs, which are currently
* contained by a {@link TabSwitcher}.
*
* @param context
* The context, which should be used by the drawable, as an instance of the class {@link
* Context}. The context may not be null
*/
public TabSwitcherDrawable(@NonNull final Context context) {
ensureNotNull(context, "The context may not be null");
Resources resources = context.getResources();
size = resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_size);
textSizeNormal =
resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_normal);
textSizeSmall =
resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_small);
background = ContextCompat.getDrawable(context, R.drawable.tab_switcher_drawable_background)
.mutate();
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.WHITE);
paint.setTextAlign(Align.CENTER);
paint.setTextSize(textSizeNormal);
paint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));
label = Integer.toString(0);
int tint = ThemeUtil.getColor(context, android.R.attr.textColorPrimary);
setColorFilter(tint, PorterDuff.Mode.MULTIPLY);
}
示例2: getColor
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* Returns the color, 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 should be obtained from, as an
* {@link Integer} value. The resource id must correspond to a valid theme attribute
* @return The color, which has been obtained, as an {@link Integer} value
*/
@ColorInt
public int getColor(@NonNull final Layout layout, @AttrRes final int resourceId) {
try {
return ThemeUtil.getColor(context, resourceId);
} catch (NotFoundException e1) {
int themeResourceId = getThemeResourceId(layout);
try {
return ThemeUtil.getColor(context, themeResourceId, resourceId);
} catch (NotFoundException e) {
themeResourceId = obtainThemeFromThemeAttributes(layout, themeResourceId);
return ThemeUtil.getColor(context, themeResourceId, resourceId);
}
}
}
示例3: TabSwitcherDrawable
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* Creates a new drawable, which allows to display the number of tabs, which are currently
* contained by a {@link TabSwitcher}.
*
* @param context
* The context, which should be used by the drawable, as an instance of the class {@link
* Context}. The context may not be null
*/
public TabSwitcherDrawable(@NonNull final Context context) {
ensureNotNull(context, "The context may not be null");
Resources resources = context.getResources();
size = resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_size);
textSizeNormal =
resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_normal);
textSizeSmall =
resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_small);
background =
ContextCompat.getDrawable(context, R.drawable.tab_switcher_drawable_background)
.mutate();
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.WHITE);
paint.setTextAlign(Align.CENTER);
paint.setTextSize(textSizeNormal);
paint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));
label = Integer.toString(0);
int tint = ThemeUtil.getColor(context, android.R.attr.textColorPrimary);
setColorFilter(tint, PorterDuff.Mode.MULTIPLY);
}
示例4: obtainButtonBarBackground
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* Obtains the background of the button bar from the activity's current theme.
*/
private void obtainButtonBarBackground() {
try {
int color =
ThemeUtil.getColor(getActivity(), R.attr.restoreDefaultsButtonBarBackground);
setButtonBarBackgroundColor(color);
} catch (NotFoundException e) {
int resourceId = ThemeUtil
.getResId(getActivity(), R.attr.restoreDefaultsButtonBarBackground, -1);
if (resourceId != -1) {
setButtonBarBackground(resourceId);
} else {
setButtonBarBackgroundColor(
ContextCompat.getColor(getActivity(), R.color.button_bar_background_light));
}
}
}
示例5: obtainDividerColor
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* Obtains the color of the dividers, which are shown above preference categories, from the
* activity's theme.
*/
private void obtainDividerColor() {
int color;
try {
color = ThemeUtil.getColor(getActivity(), R.attr.dividerColor);
} catch (NotFoundException e) {
color = ContextCompat.getColor(getActivity(), R.color.preference_divider_color_light);
}
setDividerColor(color);
}
示例6: obtainCardViewBackgroundColor
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* Obtains the background color of the card view, which contains the currently shown preference
* fragment, when using the split screen layout, from the activity's theme.
*/
private void obtainCardViewBackgroundColor() {
int color;
try {
color = ThemeUtil.getColor(this, R.attr.cardViewBackgroundColor);
} catch (NotFoundException e) {
color = ContextCompat.getColor(this, R.color.card_view_background_light);
}
setCardViewBackgroundColor(color);
}
示例7: obtainBreadCrumbBackgroundColor
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* Obtains the background color of the toolbar, which is used to show the bread crumb of the
* currently selected navigation preference, when using the split screen layout, from the
* activity's theme.
*/
private void obtainBreadCrumbBackgroundColor() {
int color;
try {
color = ThemeUtil.getColor(this, R.attr.breadCrumbBackgroundColor);
} catch (NotFoundException e) {
color = ContextCompat.getColor(this, R.color.bread_crumb_background_light);
}
setBreadCrumbBackgroundColor(color);
}
示例8: obtainNavigationSelectionColor
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* Obtains the background color of the currently selected navigation preference from the
* activity's theme.
*/
private void obtainNavigationSelectionColor() {
int color;
try {
color = ThemeUtil.getColor(this, R.attr.navigationSelectionColor);
} catch (NotFoundException e) {
color = ContextCompat.getColor(this, R.color.preference_selection_color_light);
}
setNavigationSelectionColor(color);
}
示例9: obtainNavigationDividerColor
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* Obtains the color of the dividers, which are contained by the navigation.
*/
private void obtainNavigationDividerColor() {
int color;
try {
color = ThemeUtil.getColor(this, R.attr.navigationDividerColor);
} catch (NotFoundException e) {
color = ContextCompat.getColor(this, R.color.preference_divider_color_light);
}
setNavigationDividerColor(color);
}
示例10: obtainTabIndicatorColor
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* Obtains the color of the tab indicator from a specific theme.
*
* @param themeResourceId
* The resource id of the theme, the color should be obtained from, as an {@link
* Integer} value
*/
private void obtainTabIndicatorColor(@StyleRes final int themeResourceId) {
TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(themeResourceId,
new int[]{R.attr.materialDialogTabIndicatorColor});
int defaultColor =
ThemeUtil.getColor(getContext(), themeResourceId, R.attr.colorAccent);
setTabIndicatorColor(typedArray.getColor(0, defaultColor));
}
示例11: obtainTabTextColor
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* Obtains the text color of the tabs from a specific theme.
*
* @param themeResourceId
* The resource id of the theme, the text color should be obtained from, as an
* {@link Integer} value
*/
private void obtainTabTextColor(@StyleRes final int themeResourceId) {
TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(themeResourceId,
new int[]{R.attr.materialDialogTabTextColor});
int defaultColor = ThemeUtil
.getColor(getContext(), themeResourceId, android.R.attr.textColorSecondary);
setTabTextColor(typedArray.getColor(0, defaultColor));
}
示例12: obtainTabSelectedTextColor
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* Obtains the selected text color of the tabs from a specific theme.
*
* @param themeResourceId
* The resource id of the theme, the text color should be obtained from, as an
* {@link Integer} value
*/
private void obtainTabSelectedTextColor(@StyleRes final int themeResourceId) {
TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(themeResourceId,
new int[]{R.attr.materialDialogTabSelectedTextColor});
int defaultColor = ThemeUtil
.getColor(getContext(), themeResourceId, android.R.attr.textColorSecondary);
setTabSelectedTextColor(typedArray.getColor(0, defaultColor));
}
示例13: obtainButtonTextColor
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* Obtains the button text color from a specific theme.
*
* @param themeResourceId
* The resource id of the theme, the text color should be obtained from, as an
* {@link Integer} value
*/
private void obtainButtonTextColor(@StyleRes final int themeResourceId) {
TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(themeResourceId,
new int[]{R.attr.materialDialogButtonTextColor});
int defaultColor =
ThemeUtil.getColor(getContext(), themeResourceId, R.attr.colorAccent);
setButtonTextColor(typedArray.getColor(0, defaultColor));
}
示例14: obtainProgressBarColor
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* Obtains the color of the dialog's progress bar from a specific theme.
*
* @param themeResourceId
* The resource id of the theme, the color should be obtained from, as an {@link
* Integer} value
*/
private void obtainProgressBarColor(@StyleRes final int themeResourceId) {
TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(themeResourceId,
new int[]{R.attr.materialDialogProgressBarColor});
int defaultColor =
ThemeUtil.getColor(getContext(), themeResourceId, R.attr.colorAccent);
setProgressBarColor(typedArray.getColor(0, defaultColor));
}
示例15: obtainItemColor
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* 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});
int defaultColor = ThemeUtil
.getColor(getContext(), themeResourceId, android.R.attr.textColorSecondary);
setItemColor(typedArray.getColor(0, defaultColor));
}