0

I am trying to implement a light and dark theme for my app by following This blog

But in case of changing the menu items according to the theme, by following the above no menu icon is displayed only its string This is my attrs.xml code-

<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="icon_favourite" format="reference" />
</resources>

This is my Light Theme Style

<item name="icon_favourite">@drawable/ic_liked_toolbar</item>

This is my Dark Theme Style

<item name="icon_favourite">@drawable/ic_liked_toolbar_white</item>

This is my menuitem -

<item xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/favourites"
    android:icon="?attrs/icon_favourite"
    android:title="@string/action_favourites" />

After applying all these my menu item's icon is not visible and only its string is visible

Naimish Srivastava
  • 373
  • 1
  • 3
  • 14

1 Answers1

-1

In the activity use method :

setTheme(Theme);

before calling

setContentView();

Hope this helps.

Sarthak Gandhi
  • 2,130
  • 1
  • 16
  • 23