• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ThemeUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中de.mrapp.android.util.ThemeUtil的典型用法代码示例。如果您正苦于以下问题:Java ThemeUtil类的具体用法?Java ThemeUtil怎么用?Java ThemeUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ThemeUtil类属于de.mrapp.android.util包,在下文中一共展示了ThemeUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: obtainThemeFromThemeAttributes

import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
 * Returns the resource id of the theme, which is used when using a specific layout. The theme
 * is obtained from a theme's attributes. If the theme is not specified, the
 * resource id of the default theme is returned.
 *
 * @param layout
 *         The layout as a value of the enum {@link Layout}. The layout may not be null
 * @param themeResourceId
 *         The resource id of the theme, the resource id should be obtained from, as an {@link
 *         Integer} value or -1, if the global app theme should be used
 * @return The resource id of the theme, which is used when using the given layout, as an {@link
 * Integer} value
 */
private int obtainThemeFromThemeAttributes(@NonNull final Layout layout,
                                           final int themeResourceId) {
    int resourceId = layout == Layout.TABLET ? R.attr.tabSwitcherThemeTablet :
            R.attr.tabSwitcherThemePhone;
    int result = ThemeUtil.getResId(context, themeResourceId, resourceId, 0);

    if (result == 0) {
        result = ThemeUtil.getResId(context, R.attr.tabSwitcherThemeGlobal, 0);

        if (result == 0) {
            result = R.style.TabSwitcher_Light;
        }
    }

    return result;
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:30,代码来源:ThemeHelper.java


示例3: 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


示例4: getColorStateList

import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:29,代码来源:ThemeHelper.java


示例5: getResourceId

import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
 * Returns the resource id, 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 resource id should be obtained from, as
 *         an {@link Integer} value. The resource id must correspond to a valid theme attribute
 * @param defaultValue
 *         The default value, which should be returned, if the given resource id is invalid, as
 *         an {@link Integer} value
 * @return The resource id, which has been obtained, as an {@link Integer} value
 */
public int getResourceId(@NonNull final Layout layout, @AttrRes final int resourceId,
                         final int defaultValue) {
    int result = ThemeUtil.getResId(context, resourceId, 0);

    if (result == 0) {
        int themeResourceId = getThemeResourceId(layout);
        result = ThemeUtil.getResId(context, themeResourceId, resourceId, 0);

        if (result == 0) {
            themeResourceId = obtainThemeFromThemeAttributes(layout, themeResourceId);
            return ThemeUtil.getResId(context, themeResourceId, resourceId, defaultValue);
        }
    }

    return result;
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:31,代码来源:ThemeHelper.java


示例6: getInteger

import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
 * Returns the integer value, 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 integer value should be obtained from, as
 *         an {@link Integer} value. The resource id must correspond to a valid theme attribute
 * @param defaultValue
 *         The default value, which should be returned, if the given resource id is invalid, as
 *         an {@link Integer} value
 * @return The integer value, which has been obtained, as an {@link Integer} value
 */
public int getInteger(@NonNull final Layout layout, @AttrRes final int resourceId,
                      final int defaultValue) {
    int result = ThemeUtil.getInt(context, resourceId, 0);

    if (result == 0) {
        int themeResourceId = getThemeResourceId(layout);
        result = ThemeUtil.getInt(context, themeResourceId, resourceId, 0);

        if (result == 0) {
            themeResourceId = obtainThemeFromThemeAttributes(layout, themeResourceId);
            return ThemeUtil.getInt(context, themeResourceId, resourceId, defaultValue);
        }
    }

    return result;
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:31,代码来源:ThemeHelper.java


示例7: 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


示例8: 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


示例9: onCreate

import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
@Override
protected final void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    float alpha = ThemeUtil.getFloat(this, android.R.attr.disabledAlpha);

    initializeUsernameEditText();
    initializePasswordEditText();
    initializePasswordRepetitionEditText();
    initializeGenderSpinner();
    initializeFirstNameEditText();
    initializeLastNameEditText();
    initializeAdditionalInformationEditText();
    initializeValidateButton();
}
 
开发者ID:michael-rapp,项目名称:AndroidMaterialValidation,代码行数:17,代码来源:MainActivity.java


示例10: createWindowInsetsListener

import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
 * Creates a listener, which allows to apply the window insets to the tab switcher's padding.
 *
 * @return The listener, which has been created, as an instance of the type {@link
 * OnApplyWindowInsetsListener}. The listener may not be nullFG
 */
@NonNull
private OnApplyWindowInsetsListener createWindowInsetsListener() {
    return new OnApplyWindowInsetsListener() {

        @Override
        public WindowInsetsCompat onApplyWindowInsets(final View v,
                                                      final WindowInsetsCompat insets) {
            int left = insets.getSystemWindowInsetLeft();
            int top = insets.getSystemWindowInsetTop();
            int right = insets.getSystemWindowInsetRight();
            int bottom = insets.getSystemWindowInsetBottom();
            tabSwitcher.setPadding(left, top, right, bottom);
            float touchableAreaTop = top;

            if (tabSwitcher.getLayout() == Layout.TABLET) {
                touchableAreaTop += getResources()
                        .getDimensionPixelSize(R.dimen.tablet_tab_container_height);
            }

            RectF touchableArea = new RectF(left, touchableAreaTop,
                    getDisplayWidth(MainActivity.this) - right, touchableAreaTop +
                    ThemeUtil.getDimensionPixelSize(MainActivity.this, R.attr.actionBarSize));
            tabSwitcher.addDragGesture(
                    new SwipeGesture.Builder().setTouchableArea(touchableArea).create());
            tabSwitcher.addDragGesture(
                    new PullDownGesture.Builder().setTouchableArea(touchableArea).create());
            return insets;
        }

    };
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:38,代码来源:MainActivity.java


示例11: initialize

import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
 * Initializes the view.
 */
private void initialize() {
    drawable = new TabSwitcherDrawable(getContext());
    setImageDrawable(drawable);
    ViewUtil.setBackground(this,
            ThemeUtil.getDrawable(getContext(), R.attr.selectableItemBackgroundBorderless));
    setContentDescription(null);
    setClickable(true);
    setFocusable(true);
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:13,代码来源:TabSwitcherButton.java


示例12: getDrawable

import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
 * Returns the drawable, 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 drawable 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 Drawable getDrawable(@NonNull final Layout layout, @AttrRes final int resourceId) {
    try {
        return ThemeUtil.getDrawable(context, resourceId);
    } catch (NotFoundException e1) {
        int themeResourceId = getThemeResourceId(layout);

        try {
            return ThemeUtil.getDrawable(context, themeResourceId, resourceId);
        } catch (NotFoundException e) {
            themeResourceId = obtainThemeFromThemeAttributes(layout, themeResourceId);
            return ThemeUtil.getDrawable(context, themeResourceId, resourceId);
        }
    }
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:27,代码来源:ThemeHelper.java


示例13: getText

import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
 * Returns the text, 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 text should be obtained from, as an
 *         {@link Integer} value. The resource id must correspond to a valid theme attribute
 * @return The text, which has been obtained, as an instance of the type {@link CharSequence}
 */
public CharSequence getText(@NonNull final Layout layout, @AttrRes final int resourceId) {
    try {
        return ThemeUtil.getText(context, resourceId);
    } catch (NotFoundException e1) {
        int themeResourceId = getThemeResourceId(layout);

        try {
            return ThemeUtil.getText(context, themeResourceId, resourceId);
        } catch (NotFoundException e) {
            themeResourceId = obtainThemeFromThemeAttributes(layout, themeResourceId);
            return ThemeUtil.getText(context, themeResourceId, resourceId);
        }
    }
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:26,代码来源:ThemeHelper.java


示例14: 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


示例15: obtainRestoreDefaultsButtonText

import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
 * Obtains the text of the button, which allows to restore the preferences' default values, from
 * the activity's current theme.
 */
private void obtainRestoreDefaultsButtonText() {
    CharSequence text;

    try {
        text = ThemeUtil.getText(getActivity(), R.attr.restoreDefaultsButtonText);
    } catch (NotFoundException e) {
        text = getText(R.string.restore_defaults_button_text);
    }

    setRestoreDefaultsButtonText(text);
}
 
开发者ID:michael-rapp,项目名称:AndroidPreferenceActivity,代码行数:16,代码来源:PreferenceFragment.java


示例16: obtainButtonBarElevation

import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
 * Obtains the elevation of the button bar from the activity's current theme.
 */
private void obtainButtonBarElevation() {
    int elevation;

    try {
        elevation = ThemeUtil
                .getDimensionPixelSize(getActivity(), R.attr.restoreDefaultsButtonBarElevation);
    } catch (NotFoundException e) {
        elevation = getResources().getDimensionPixelSize(R.dimen.button_bar_elevation);
    }

    setButtonBarElevation(pixelsToDp(getActivity(), elevation));
}
 
开发者ID:michael-rapp,项目名称:AndroidPreferenceActivity,代码行数:16,代码来源:PreferenceFragment.java


示例17: obtainNavigationWidth

import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
 * Obtains the width of the navigation from the activity's theme.
 */
private void obtainNavigationWidth() {
    int navigationWidth;

    try {
        navigationWidth = ThemeUtil.getDimensionPixelSize(this, R.attr.navigationWidth);
    } catch (NotFoundException e) {
        navigationWidth = getResources().getDimensionPixelSize(R.dimen.navigation_width);
    }

    setNavigationWidth(navigationWidth);
}
 
开发者ID:michael-rapp,项目名称:AndroidPreferenceActivity,代码行数:15,代码来源:PreferenceActivity.java


示例18: obtainNextButtonText

import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
 * Obtains the text of the next button from the activity's theme.
 */
private void obtainNextButtonText() {
    CharSequence text;

    try {
        text = ThemeUtil.getText(this, R.attr.nextButtonText);
    } catch (NotFoundException e) {
        text = getText(R.string.next_button_text);
    }

    setNextButtonText(text);
}
 
开发者ID:michael-rapp,项目名称:AndroidPreferenceActivity,代码行数:15,代码来源:PreferenceActivity.java


示例19: obtainBackButtonText

import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
 * Obtains the text of the back button from the activity's theme.
 */
private void obtainBackButtonText() {
    CharSequence text;

    try {
        text = ThemeUtil.getText(this, R.attr.backButtonText);
    } catch (NotFoundException e) {
        text = getText(R.string.back_button_text);
    }

    setBackButtonText(text);
}
 
开发者ID:michael-rapp,项目名称:AndroidPreferenceActivity,代码行数:15,代码来源:PreferenceActivity.java


示例20: obtainFinishButtonText

import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
 * Obtains the text of the finish button from the activity's theme.
 */
private void obtainFinishButtonText() {
    CharSequence text;

    try {
        text = ThemeUtil.getText(this, R.attr.finishButtonText);
    } catch (NotFoundException e) {
        text = getText(R.string.finish_button_text);
    }

    setFinishButtonText(text);
}
 
开发者ID:michael-rapp,项目名称:AndroidPreferenceActivity,代码行数:15,代码来源:PreferenceActivity.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GuiScreenResourcePacks类代码示例发布时间:2022-05-22
下一篇:
Java HttpsUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap