androidxmlandroid-studio

Buttons hiding behind android action bar


I have some buttons in the bottom of my layout but they appear behind the action bar... How can I solve it?

my xml starts like this:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">
    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

How it appears in the bottom (you can see the round buttons behind the bar):

enter image description here

p.s.: I'm using emulator, I don't know if there's any difference using a real device.


Solution

  • The issue is likely not in your XML layout but in the Activity where this view is used. I suspect that edge-to-edge display might be enabled, causing your views to extend behind the action bar and system bar.

    To fix this, check the Activity for any code like enableEdgeToEdge() or something similar. If you find such a line, simply remove it