0

On android 7 (nexus phone) the title in my context menu appears white. I would expect it to be black as it is on all other devices I tested. The rest of the app looks good.

Update: I figured out that the colorAccent is the culprit (AppCompat styles various things based on that). I set it to white in a child theme because the tabBar needs to have white tab indicators.

So now the issues is that I need white tab indicators in the actionbar, black titles in dialogs and context menus and Orange text on buttons styled with the Button.Borderless.Colored style. All of these seem to be controlled with colorAccent. I can make a seperate style for the buttons. But the styles of the dialogs and tab indicators are still conflicting. For legacy reasons I cannot use the new toolbar with a tablayout (That one is stylable) but have to use the Actionbar. Any ideas?

White title in context menu screenshot:

enter image description here

Thanks in advance!

Theme:

<resources> 

<!-- default theme -->
<style name="Theme.MyApp" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Remove actionbar -->
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>

    <!-- Basic coloring -->
    <item name="colorPrimary">@color/MyAppOrange</item>
    <item name="colorPrimaryDark">@color/MyAppOrangeDark</item>
    <item name="colorAccent">@color/MyAppOrangeDark</item>

    <!-- AppCompat dialog themes -->
    <item name="dialogTheme">@style/Theme.MyApp.Dialog</item>
    <item name="alertDialogTheme">@style/Theme.MyApp.Dialog.Alert</item>

///// Tried this with a custom style but that just f*cked up my tabs...
<item name="actionBarTabStyle">@style/CustomActionBarTabs</item>
</style>

<!-- Alert and dialog styles -->
<style name="Theme.MyApp.Dialog" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorPrimary">@color/MyAppOrange</item>
    <item name="colorPrimaryDark">@color/MyAppOrangeDark</item>
    <item name="colorAccent">@color/MyAppOrangeDark</item>
</style>

<style name="Theme.MyApp.Dialog.Alert" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="colorPrimary">@color/MyAppOrange</item>
    <item name="colorPrimaryDark">@color/MyAppOrangeDark</item>
    <item name="colorAccent">@color/MyAppOrangeDark</item>
</style>

</resources>    
Djangow
  • 341
  • 3
  • 9

1 Answers1

0

Djangow, you need to define a new style that with the text color as the specific color you want and then set that style in the app theme you want to use. See this link for the exact coding needed.

UPDATE: Djangow, I apologize. I looked into it and found that you have to add this line <item name="android:actionMenuTextColor">@color/your_color</item> to the main App theme. I found the answer here. Hope that helps

Community
  • 1
  • 1
Ovidio Reyna
  • 146
  • 1
  • 9
  • I cannot find what style I should override to set the color of the title of the context menu. Your link seems to link to setting the color of the title of the actionbar. I know how to do that ;) Also pretty old not using the appcompat theme. – Djangow Oct 19 '16 at 14:23
  • Djangow, see the update I just added to my answer. I read your initial question wrong. Hopefully that helps. – Ovidio Reyna Oct 19 '16 at 14:29