How to set icon color of MenuItem?

后端 未结 9 697
面向向阳花
面向向阳花 2021-01-30 12:37

I defined a menu item that has ShareActionProvider and share white icon like so :



        
相关标签:
9条回答
  • 2021-01-30 13:14

    This is a theming issue. Depending on your current theme, you need to set the correct ActionBar overlay theme. The Action Provider reads a value in the theme (which indicates if the theme is dark or light) to determine the color of the icon.

    If your main theme is light and your ActionBar is dark, your ActionBar/Toolbar must use the theme ThemeOverlay.AppCompat.Dark.ActionBar.

    0 讨论(0)
  • 2021-01-30 13:19

    short Answer --> use app:iconTint="?android:textColorPrimary" if you want the icon color to be white, write: android:theme = "@style/ThemeOverlay.MaterialComponents.Dark.ActionBar" else if you want black color, write: android:theme="@style/ThemeOverlay.MaterialComponents.Light" to your toolbar

    0 讨论(0)
  • 2021-01-30 13:19
     app:iconTint="@color/colorWhite" 
    

    add this in Navigational view properties

    Ex -

    <com.google.android.material.navigation.NavigationView
            android:id="@+id/nav_view"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:background="@color/main_color"
            app:itemBackground="@drawable/divider_menu_items"
            app:itemTextColor="@color/colorWhite"
            app:itemIconTint="@color/colorWhite"
            app:menu="@menu/activity_main_drawer"/>
    

    Adding this all menu item icons convert to color given by you.

    0 讨论(0)
提交回复
热议问题