java - BottomNavigationView 中的徽章在主题更改后没有改变颜色
问题描述
我已经在我的 Android 应用程序中实现了主题更改逻辑。不幸的是,当我更改主题并在 BottomNavigationView 中调用重新创建功能徽章时,背景颜色没有改变,请找到我的代码:
private void setBadge(Integer newMessageCount) {
BadgeDrawable badge = bottomNav.getOrCreateBadge(R.id.nav_messages);
badge.setNumber(newMessageCount);
badge.setBackgroundColor(ThemeColors.getColor(this, R.attr.secondaryColor));
badge.setBadgeTextColor(ThemeColors.getColor(this, R.attr.secondaryTextColor));
}
public class ThemeColors {
public static @ColorInt
int getColor(Context context, int attrColor) {
return ContextCompat.getColor(context, getColorResourceId(context, attrColor));
}
public static int getColorResourceId(Context context, int attrColor) {
TypedValue typedValue = new TypedValue();
context.getTheme().resolveAttribute(attrColor, typedValue, true);
return typedValue.resourceId;
}
}
你能告诉我为什么背景颜色没有改变吗?问候
解决方案
推荐阅读
- c# - 实体框架核心放置操作不起作用
- sql - 迭代数据以标记具有 N 连续小时的 ID
- r - R闪亮的基本问题
- excel - VBA将2个用户表单文本框中的值合并到第三个文本框中
- javascript - 我的 JavaScript 弹出模式仅适用于第一项?
- php - 为什么我无法通过网络连接到托管在 aws 上的 Wordpress 网站?
- c - 在 C 中为字符串数组动态分配内存
- typescript - TypeORM 延迟加载更新父在子保存时失败
- python - python - 如何在Python中构建一个所有值都是[]的独立实例的字典?
- php - 为什么电子邮件标题必须用“\r\n”分隔?