当前位置: 首页>>代码示例>>Java>>正文


Java ThemeUtil.getColor方法代码示例

本文整理汇总了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);
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:28,代码来源:TabSwitcherDrawable.java

示例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);
        }
    }
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:27,代码来源:ThemeHelper.java

示例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);
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:29,代码来源:TabSwitcherDrawable.java

示例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));
        }
    }
}
 
开发者ID:michael-rapp,项目名称:AndroidPreferenceActivity,代码行数:21,代码来源:PreferenceFragment.java

示例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);
}
 
开发者ID:michael-rapp,项目名称:AndroidPreferenceActivity,代码行数:16,代码来源:AbstractPreferenceFragment.java

示例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);
}
 
开发者ID:michael-rapp,项目名称:AndroidPreferenceActivity,代码行数:16,代码来源:PreferenceActivity.java

示例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);
}
 
开发者ID:michael-rapp,项目名称:AndroidPreferenceActivity,代码行数:17,代码来源:PreferenceActivity.java

示例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);
}
 
开发者ID:michael-rapp,项目名称:AndroidPreferenceActivity,代码行数:16,代码来源:PreferenceActivity.java

示例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);
}
 
开发者ID:michael-rapp,项目名称:AndroidPreferenceActivity,代码行数:15,代码来源:PreferenceActivity.java

示例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));
}
 
开发者ID:michael-rapp,项目名称:AndroidMaterialDialog,代码行数:15,代码来源:WizardDialog.java

示例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));
}
 
开发者ID:michael-rapp,项目名称:AndroidMaterialDialog,代码行数:15,代码来源:WizardDialog.java

示例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));
}
 
开发者ID:michael-rapp,项目名称:AndroidMaterialDialog,代码行数:15,代码来源:WizardDialog.java

示例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));
}
 
开发者ID:michael-rapp,项目名称:AndroidMaterialDialog,代码行数:15,代码来源:WizardDialog.java

示例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));
}
 
开发者ID:michael-rapp,项目名称:AndroidMaterialDialog,代码行数:15,代码来源:ProgressDialog.java

示例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));
}
 
开发者ID:michael-rapp,项目名称:AndroidMaterialDialog,代码行数:15,代码来源:AbstractListDialogBuilder.java


注:本文中的de.mrapp.android.util.ThemeUtil.getColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。