3

I used a toolbar in my Android application for years and never had a problem with it, but starting with Android 15 (API Level 35) my toolbar icons got overlayed with system Android icons on the top of the screen (see power button in the right upper corner overlapped with system's battery icon). Is there any way to fix it? The resource describing the toolbar is as follows:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<item
 android:id="@+id/watch"
 android:orderInCategory="2"
 app:showAsAction="always"
 android:visible="true"
 android:title=""
 android:icon="@drawable/gear"
 />
<item
 android:id="@+id/show"
 android:orderInCategory="3"
 app:showAsAction="always"
 android:visible="true"
 android:icon="@drawable/eye"
 android:title=""
 />
<item
 android:id="@+id/copy"
 android:orderInCategory="4"
 app:showAsAction="always"
 android:visible="true"
 android:icon="@drawable/copy"
 android:title=""
 />
<item
 android:id="@+id/delete"
 android:orderInCategory="5"
 app:showAsAction="always"
 android:visible="true"
 android:icon="@drawable/delete"
 android:title=""
 />
<item
 android:id="@+id/exit"
 android:orderInCategory="6"
 app:showAsAction="always"
 android:visible="true"
 android:icon="@drawable/power"
 android:title=""
 />
</menu>

The toolbar's layout is very much standard as well and is derived from the MaterialToolbar according to the Google's guidelines:

<com.google.android.material.appbar.MaterialToolbar
 android:id="@+id/rootToolbar"
 android:minHeight="?attr/actionBarSize"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:background="?android:attr/colorPrimaryDark"/>

enter image description here

asked Jan 16, 2025 at 2:27

3 Answers 3

4

You are probably missing android:fitsSystemWindows="true" in the root layout that hosts your toolbar. Check the changes introduced by Android 15 (see 3rd bullet point).

answered Jan 16, 2025 at 11:19
Sign up to request clarification or add additional context in comments.

2 Comments

I'll check it out. Thanks. Breaking apps with each new release becomes Google's tradition
See my answer. The setting you provided erases the system icons, and I don't like it. If you know what else I can tweak, please share
2

If you are using AppBarLayout, you have to add android:fitsSystemWindows="true" to it.

Add it to the AppBarLayout and not to the root layout. Adding it to the root will move the complete view down, which is usually not what you want.

For reference: https://developer.android.com/about/versions/15/behavior-changes-15?hl=de#not-edge-to-edge

answered Feb 17, 2025 at 10:03

1 Comment

As you've seen in the OP I'm using the following toolbar class. Will your solution work with the MaterialToolbar? <com.google.android.material.appbar.MaterialToolbar
0

The suggested answer solves the problem partially: it does offset the app's view, but it also erases the system icons. enter image description here

I don't want them to be erased, because they might have a value for a user, and this is how it was in all Android versions up to API 34.

My solution looks more like a hack but it fixes the problem and makes the app look like in API 34 and all prior version

 if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.VANILLA_ICE_CREAM){
 binding.rootToolbar.setPadding(0,
 binding.rootToolbar.minimumHeight/2, 0, 0)
 }

Yes, it's ugly but it works and now I have what I wanted: Thanks Google for breaking the code again.

enter image description here

@atzarul, if you know what else I can tweak in API 35 to return to the old look, please share

answered Feb 9, 2025 at 22:57

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.