black line on landscape mode (Android Studio app)

81 Views Asked by At

(Android Studio app) What should I do if in horizontal mode a black bar appears near the front camera? (The same thing happened in vertical mode, but after EdgeToEdge.enable(this); in vertical mode the black bar disappeared, but in horizontal mode it did not disappear)

Activity.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#20f020"
    tools:context=".MainActivity">


</androidx.constraintlayout.widget.ConstraintLayout>

Activity.java

package com.example.myapplication;
import android.os.Bundle;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        EdgeToEdge.enable(this);
    }
}

vertical mode

horizontal mode (with black line)

2

There are 2 best solutions below

1
Niraj Bhadani On

please add some top-layout_margin like.....

 android:layout_marginTop="5dp"
2
Niraj Bhadani On

please add some top-layout_margin like.....

 android:layout_marginTop="5dp"

First you can remove the actionbar and then you can try it.