仅在HTC愿望系列对话框中的白色背景上的白色字体
问题描述:
我的应用程序仅在HTC愿望系列手机上的片段对话框中的白色背景上显示白色字体。其他设备在白色背景上显示适当的黑色字体。如何解决这个问题。请帮忙。仅在HTC愿望系列对话框中的白色背景上的白色字体
private void adjustResourceLightness() {
// change up button to light version if using dark theme
int color = 0xFFFFFF;
getActivity().setTheme(0);
final Resources.Theme theme = getActivity().getTheme();
if (theme != null) {
TypedArray backgroundAttributes = theme.obtainStyledAttributes(
new int[]{android.R.attr.colorBackground});
if (backgroundAttributes != null) {
color = backgroundAttributes.getColor(0, 0xFFFFFF);
backgroundAttributes.recycle();
}
}
// convert to greyscale and check if < 128
if (color != 0xFFFFFF && 0.21 * Color.red(color) +
0.72 * Color.green(color) +
0.07 * Color.blue(color) < 128) {
mBtnNavUp.setImageResource(R.drawable.navigation_up_light);
mBtnCreateFolder.setImageResource(R.drawable.ic_action_create_light);
}
}
答
它与htc的错误。你必须使用Theme.AppCompat.Light.DarkActionBar 尝试设置 context.setTheme(0)在调用context.getTheme()。setTo(widgetTheme)之前
好吧,我会试试看。 – SANAT
我使用Theme.AppCompat.Light.DarkActionBar并添加context.setTheme(0)之前调用context.getTheme()。setTo(widgetTheme),因为你告诉,但它不工作。如果您有任何想法,请帮助我。 – SANAT
我正在使用该库进行目录选择:https://github.com/passy/Android-DirectoryChooser并且发生此问题。 – SANAT