rubberBoy
rubberBoy

Reputation: 35

How to make the image fit the whole screen, including the upper part

I'm having some trouble styling my app, I want to make the background image to fit the whole screen including the part where the wifi icon and the battery percent. I looked up the older answers but it seems that the android:scaleType isn't there for the autocompletion so I guess it may have been dropped. Can anyone help me? And by this I mean to make the image height to be as big as the actual screen.

<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:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:background="@drawable/books_background"
tools:context=".MainActivity">
</androidx.constraintlayout.widget.ConstraintLayout>

Upvotes: 1

Views: 51

Answers (1)

MMG
MMG

Reputation: 3268

Use this code before setContentViewin onCreate:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN)

Upvotes: 1

Related Questions