Androidx Navigation icon compatability issues in Android 7

Viewed 421

I am using com.google.android.material.appbar.AppBarLayout along with androidx.appcompat.widget.Toolbar in my app and in Android 8 it works perfectly but I am having an issue where the 'hamburger' menu icon and 'back' icons are just displaying as a white block in android 7 (API 24 & API 25) even though other menu icons are displayed correctly.

Where the hamburger icon is showing.

where the hamburger icon looks like

And what the back button looks like.

what the back button looks like

My app bar layout:

<com.google.android.material.appbar.AppBarLayout
        android:id="@+id/activity_drawer_layout_app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary" />

    </com.google.android.material.appbar.AppBarLayout>

And just setting up the toolbar:

setSupportActionBar ( toolbar )

    actionBar?.setDisplayShowCustomEnabled(true)
    actionBar?.setDisplayShowCustomEnabled(true)
    actionBar?.setDisplayHomeAsUpEnabled(true)
    actionBar?.setDisplayShowHomeEnabled(true)
    actionBar?.setDisplayShowTitleEnabled(true)
2 Answers

As you are using Material library this is the expected result. I don't know how the compiler in Android 8 override the material theme settings by default. If you use material library color tints are by default applied. For more details have a look at https://material.io/design/color/applying-color-to-ui.html#usage.
You will learn everything about Material library at that website.

You may apply tint or background color in theme.

If you not able to find the problem -> add ImageView(for back button) inside Toolbar

ex:

<Toolbar>
   <ImageView>
 </Toolbar>
Related