我在styles.xml中使用如下主题:

<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="colorPrimary">@color/md_blue_700</item>
    <item name="android:colorAccent">@color/md_blue_900</item>
    <item name="android:colorPrimaryDark">@color/md_blue_900</item>
    <item name="android:windowBackground">@color/md_white_1000</item>
    <item name="android:colorControlNormal">@color/md_blue_700</item>
    <item name="android:colorControlActivated">@color/md_blue_700</item>
    <item name="android:colorControlHighlight">@color/md_blue_700</item>
    <item name="android:textColorPrimary">@color/md_white_1000</item>
</style>

我在AndroidManifest.xml中声明为android:theme:
 <activity
        android:name=".LoginActivity"
        android:theme="@style/AppTheme"
        android:label="@string/activity_login_actionbar" />

问题在下图中以红色突出显示。

因为我在设定
<item name="android:textColorPrimary">@color/md_white_1000</item>

将进度条中的文本显示为白色也将显示为白色且不可见。如果我将其更改为灰色,则操作栏中的文本也会更改为我不希望的灰色。

我已经尝试过诸如为进度对话框创建单独的主题之类的事情,但是当我这样做时,我会丢失对话框等的圆角。

这是我用于创建微调器的Java代码:
progressDialog = new ProgressDialog(this);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setTitle("Attempting Sign In");
progressDialog.setMessage("Please wait...");
progressDialog.setCancelable(false);

我应该如何解决这个问题?

所有答案表示赞赏!

java - Android操作栏文本自定义颜色-LMLPHP

最佳答案

您可以使用Theme.AppCompat.Light.DarkActionBar并删除主题样式中的<item name="android:textColorPrimary">@color/md_white_1000</item>,然后标题将变为白色。您可以检查Light and Dark themes here之间的比较

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/md_blue_700</item>
    <item name="android:colorAccent">@color/md_blue_900</item>
    <item name="android:colorPrimaryDark">@color/md_blue_900</item>
    <item name="android:windowBackground">@color/md_white_1000</item>
    <item name="android:colorControlNormal">@color/md_blue_700</item>
    <item name="android:colorControlActivated">@color/md_blue_700</item>
    <item name="android:colorControlHighlight">@color/md_blue_700</item>
</style>

09-05 12:56
查看更多