Search code examples
androidandroid-layoutandroid-studioandroid-activityandroid-designer

Background image of screen size


I have a problem with the background image of my login activity. I can't remove the white bar at the top of the background image... Someone can help me?

In preview:

enter image description here

In my smartphone:

enter image description here

Here is my Relative Layout code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/login_background"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.project.main.application.view.activity.Av_Login">


Solution

  • Add below line of code

    requestWindowFeature(Window.FEATURE_NO_TITLE);
            super.onCreate(savedInstanceState);
            if (Build.VERSION.SDK_INT < MINIMUM_API_LEVEL) {
                getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            } else {
                getWindow().getDecorView().setSystemUiVisibility(
                        View.SYSTEM_UI_FLAG_FULLSCREEN);
            }