Skip to content

Android 15 system window insets #137

Open

Description

@larrychips

Nav bar obscures keyboard when used on Android 15

When running on a device running API 35 or above, the keyboard is partially obscured by system bars. This issue also affects the main activity.

Symptoms

Running on an emulator with an API level 35 image, or on my phone, the main activity and keyboard are obscured.

This is the activity with its content scrolled up as far as it will go:

Image

and in landscape:

Image

And here is the keyboard:

Image Image Image

This also affects the default keyboard in the emulator's system image (which is an AOSP one without Google Play). It does not affect the default Samsung keyboard on my phone.

Cause

Android 15 puts apps in "edge to edge" mode, where they are drawn under the system bars and must adjust their padding accordingly.
That explains the obscured parts of the views, but I have no idea why the phenomenon in the second last image occurs, where the left edge of the keyboard is not obscured but the width seems not to be sufficiently narrower to fit it all on screen.

Attempted fix

I am not very familiar with Android development, so I have been down a rabbit hole trying to fix this.

The first thing I tried, is reverting targetSdk to 34. I thought that Android would try to make older apps work as if they were running on an older version of Android. That did not work. Of course that would not be a real solution anyway, long term.

edit: There was a paragraph here about my misunderstanding of WindowInsets, specifically arising from the fact that I thought WindowInsets.getInsets(int) returned a WindowInsets, but it returns an Insets

In any case, it didn't work.

But it seems there is also a fitsSystemWindows attribute of views which can be set in a layout file or at runtime. That fixes the activity views, but not the keyboard. I think it may be to do with the keyboard being inside a subclass of Dialog called SoftInputWindow, which is used by the InputMethodService class. Perhaps that doesn't get WindowInsets applied automatically. I have no idea.

Here is the tiny patch that adds fitsSystemWindows everywhere: larrychips/codeboard@c552594

diff --git a/app/src/main/java/com/gazlaws/codeboard/layout/ui/KeyboardUiFactory.java b/app/src/main/java/com/gazlaws/codeboard/layout/ui/KeyboardUiFactory.java
index 8010be4..5922d34 100644
--- a/app/src/main/java/com/gazlaws/codeboard/layout/ui/KeyboardUiFactory.java
+++ b/app/src/main/java/com/gazlaws/codeboard/layout/ui/KeyboardUiFactory.java
@@ -31,6 +31,7 @@ public class KeyboardUiFactory {
             View view = createKeyView(context, key, uiTheme);
             layout.addView(view,params);
         }
+        layout.setFitsSystemWindows(true);
         return layout;
     }
 
diff --git a/app/src/main/res/layout/codeboard_intro1.xml b/app/src/main/res/layout/codeboard_intro1.xml
index d24bc51..5914d19 100644
--- a/app/src/main/res/layout/codeboard_intro1.xml
+++ b/app/src/main/res/layout/codeboard_intro1.xml
@@ -3,7 +3,8 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="@color/colorPrimaryDark"
-    android:orientation="vertical">
+    android:orientation="vertical"
+    android:fitsSystemWindows="true">
 
     <TextView
         android:layout_width="wrap_content"
@@ -43,4 +44,4 @@
         android:layout_marginBottom="64dp"
         android:src="@drawable/enable_screenshot" />
 
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/app/src/main/res/layout/codeboard_intro2.xml b/app/src/main/res/layout/codeboard_intro2.xml
index 3a80e75..78a39b2 100644
--- a/app/src/main/res/layout/codeboard_intro2.xml
+++ b/app/src/main/res/layout/codeboard_intro2.xml
@@ -3,7 +3,8 @@
     android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="@color/colorPrimaryDark">
+    android:background="@color/colorPrimaryDark"
+    android:fitsSystemWindows="true">
     <TextView
         android:layout_margin="48dp"
         android:textStyle="bold"
@@ -33,4 +34,4 @@
         android:src="@drawable/icon_large"
         android:layout_marginBottom="64dp"/>
 
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/app/src/main/res/layout/new_activity_main.xml b/app/src/main/res/layout/new_activity_main.xml
index 2a09f1a..ed1d87a 100644
--- a/app/src/main/res/layout/new_activity_main.xml
+++ b/app/src/main/res/layout/new_activity_main.xml
@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical" android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="match_parent"
+    android:fitsSystemWindows="true">
     <FrameLayout
         android:id="@+id/settings_container"
         android:layout_width="match_parent"
         android:layout_height="match_parent">
     </FrameLayout>
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>

Activity

  1. larrychips commented on Jul 26, 2025

    @larrychips
    Author

    Sorry, I said "in the last image" when I was not referring to the last image.

  2. CloCkWeRX commented on Sep 9, 2025

    @CloCkWeRX

    this affects the ux on my pixel

    Image
  3. CloCkWeRX commented on Sep 9, 2025

    @CloCkWeRX
  4. Joe0lsen commented on Nov 8, 2025

    @Joe0lsen

    Would love to see this issue resolved! 🙏

  5. added a commit that references this issue on Nov 19, 2025
  6. larrychips commented on Nov 20, 2025

    @larrychips
    Author

    My phone just got a system update from Samsung, and am now on Android 16.
    Codeboard's actual keyboard works fine now, but the activity views still need their fitsSystemWindows properties setting.

    It seems that the other half of the fix might only need to apply when on api level 35 (not above or below).
    It's a bit ugly, but it would mean telling codeboard's KeyboardLayoutView to add padding corresponding to the window right inset, reducing its width by the left inset, and adding bottom padding for the bottom inset, and ignoring the top inset. Again, this is only to be done when android.os.Build.SDK_INT == 35. This is a horrible kludge but it is simple and only applies when running on this one version of Android. It also only works if everyone is seeing exactly the same symptoms; obscured right edge if there is a system bar there, obscured bottom if there is a system bar there, and disappearing off the right edge if there is a system bar on the left.

  7. MrFaul commented on Dec 4, 2025

    @MrFaul

    This is an issue for a lot of people right now.
    An easy clutch in the meantime would be configurable offsets in the settings.

  8. sk-Prime commented on Dec 5, 2025

    @sk-Prime

    I am facing this issue too.

  9. proidit commented on Dec 9, 2025

    @proidit

    same problem. i see this is old issue. no solution... no possible to use it...

  10. arjunahmads20 commented on Jan 5, 2026

    @arjunahmads20

    The bug only appears in my phone when it is in landscape mode. So I fixed this by adding this if statement inside the KeyboardLayoutView.java -> onMeasure().

    if (availableHeight < avaliableWidth) { availableWidth = (int) (availableWidth * 0.92f); }

    Screenshot:
    Image

    Link of the resulting apk:
    https://drive.google.com/file/d/1ctoGLuK3c0pMLn0iuTZtHwPsc8vO3R6J/view?usp=drivesdk

  11. sk-Prime commented on Jan 6, 2026

    @sk-Prime

    Image

    the problem is still there. I installed the attached apk from gdrive.

    The problem was not in android 14, i am facing this issue after updating to android 15.

  12. arjunahmads20 commented on Jan 7, 2026

    @arjunahmads20

    @sk-Prime Have you tried it in landscape mode?

  13. larrychips commented on Jan 7, 2026

    @larrychips
    Author

    The horrible kludge I committed a while ago is now available as a release with a built and signed APK here. I don't know if this works for everyone: it is, as I said, a horrible kludge.

  14. iwansal64 commented on Sep 19, 2026

    @iwansal64

    It seems this problem has been solved!

    I'm using the latest version from github and it worked perfectly fine. The bug still exists if you install it from playstore though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions