Theme.Sherlock.Light.DarkActionBar中的隐形ActionMode项目图标

Nat*_*tix 14 android android-theme

当使用Theme.Sherlock.Light.DarkActionBar(或Theme.Holo.Light.DarkActionBar没有区别)时,例如在选择文本时出现的ActionMode(或"上下文ActionBar")默认情况下与标准黑暗主题中的样式相同,即带有光的深蓝色行动图标.

但是,当您尝试在对话框中选择文本时(在此主题中为浅色调,与黑色ActionBar形成对比),将显示与Light主题(白色背景)中样式相同的ActionMode.问题是,它的动作图标不是应该是暗的,而是亮的,使它们实际上不可见.

在此输入图像描述

这看起来好像背景是从光主题中获取的(因为光对话框),但是图标是从黑暗主题中拍摄的.这是Light.DarkActionBar主题中的错误吗?我能为此做些什么吗?

Bas*_*ngh 9

自从过去两天以来,我一直在为同一个问题而战.最后我想出了一个解决方法!

我使用的是DialogFragment同一个AlertDialog对象.在该onCreateDialog()方法中,我们所要做的就是获取父活动的上下文并再次将其主题设置为Theme.Light.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    //get the parent activity context and set it's theme again.
    Context ctx = getActivity();
    ctx.setTheme(android.R.style.Theme_Holo_Light);
    AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.your_dialog_layout, null, false);
    builder.setView(view);

    //your other code for the dialog
    //

    return builder.create();
Run Code Online (Sandbox Code Playgroud)

现在Contextual ActionBar中的图标EditText具有正确的颜色.