thankyoukindly
thankyoukindly

Reputation: 35

Android API 16 MenuItem and Navigation Drawer Icon BackgroundColor

My App uses the AppCompat Library and is targeting v23 and minSDK is v16. I currently have an activity with a Navigation Drawer Fragment and I switch between 3 different fragments on my Main Activity.

My AppCompatToolbar color is blue, and my Activity background is gray.

On API 16: My Navigation Drawer icon (set as home button) and any MenuItem that is inflated from my fragments have a gray background around them on top of my blue toolbar.

On API 17+: Everything looks good. icon and MenuItems use the toolbar color.

Unfortunately I can't show pictures because I don't have enough rep but you get the idea.

I'm not doing anything funky in onPrepareOptionsMenu or onCreateOptionsMenu.I could not find any information on this and it's only happening on devices running API 16. Heres the relevant themes from styles.xml I'll paste whatever code is necessary.

<style name="AppThemeWhite" parent="AppTheme.Base">
    <item name="android:textColor">#ffffff</item>
    <item name="android:textColorSecondary">#FFFFFF</item>
    <item name="android:textColorTertiary">#FFFFFF</item>
    <item name="actionMenuTextAppearance">@style/ActionMenuItemWhite</item>
    <item name="actionMenuTextColor">@android:color/white</item>
</style>

<!-- Base application theme. -->
<style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="windowActionBarOverlay">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:editTextStyle">@style/LightEditText</item>
    <item name="alertDialogTheme">@style/CustomAlertDialog</item>
    <item name="colorAccent">@android:color/white</item>
    <item name="colorControlHighlight">@color/appButtonHighlightColor</item>
    <item name="android:textSize">@dimen/material_text_button</item>
    <item name="colorButtonNormal">@color/appButtonColor</item>
    <item name="colorPrimary">@color/appToolbarColor</item>
    <item name="colorPrimaryDark">@color/appStatusBarColor</item>
    <item name="android:dividerHeight">1px</item>
    <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
    <!-- Customize your theme here. -->
</style> 
<style name="ToolbarTheme" parent="Base.ThemeOverlay.AppCompat.ActionBar">
    <item name="actionMenuTextColor">@android:color/white</item>
    <item name="android:actionMenuTextAppearance">@style/ActionMenuItemWhite</item>
</style>
   <style name="ActionMenuItemWhite" parent="Widget.AppCompat.Light.ActionButton">
    <item name="actionMenuTextColor">@color/appTextColor</item>
    <item name="android:background">@android:color/transparent</item>
    <item name="android:textSize">@dimen/material_text_menu</item>
</style>

Upvotes: 0

Views: 495

Answers (3)

Jignesh Goyani
Jignesh Goyani

Reputation: 1020

Please try change appcompat-v7 library version

  compile 'com.android.support:appcompat-v7:23.1.1'

Bcoz not support v7:23.2+

Upvotes: 0

Alexandr Shutko
Alexandr Shutko

Reputation: 1875

Sometimes styling needs both android:name items and name to support older androids and custom widgets... Example:

<item name="android:editTextStyle">@style/LightEditText</item>
<item name="editTextStyle">@style/LightEditText</item>

Also you can try to add this to your AppTheme.Base style:

<item name="actionButtonStyle">@style/ActionMenuItemWhite</item>

Upvotes: 0

JamisonMan111
JamisonMan111

Reputation: 200

I might be misunderstanding here, but why are their MenuItems being inflated from Fragments? Normally the "v7.appcompat.toolbar" inflates it's MenuItems in the Main Activity.

Also just FYI, but in the recent past when I have tried to change some of the "ToolBar" settings by changing the "ActionBar" settings in the styles/themes, I have had mixed and unreliable results myself.

Why did you choose 16 as your minimum? It can be very tricky to have your App be backwards compatible starting from API 23 because there is a lot of code that doesn't work the same in Android when comparing pre-API 21 to post-API 21.

Upvotes: 0

Related Questions