How to make android studio layout (XML) extend to the very top of the screen

Viewed 38

I am trying to make an android app that with accesibility permissions draws over any app at the very top of my phone (at the status bar). The problem is that the top of the XML is not the top of the screen, it stays below the status bar. And yes, my app is at full screen mode (copyed some code of the full screen activity template in android studio). This is my first post and I am starting to android studio. Thanks in advance.

1 Answers

create a new Style in Styles.xml and use it under the activity you want as full screen , it will cover the status bar

<style name="Theme.fullScreen" parent="Theme."MainTheme">

    <item name="android:windowLayoutInDisplayCutoutMode" 
     tools:targetApi="o_mr1">shortEdges</item>
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
</style>
Related