Skip to content Skip to sidebar Skip to footer

Background Image In Constraints Layout Does Not Work

I want my app to use a image in the background for signup and signin function. I am using android studio 2.3 and so far I can see that lot many things have changed since last year.

Solution 1:

The resolution of your image is too large for the device resize your picture to smaller dimesions and based on that put your image into specific drawable folder. e.g : If image size is 1280 x 720 than put image in drawable-xxhdpi folder.


Solution 2:

To prevent Bitmap too large error, you can simply use libraries like Glide or Picasso. These libraries take care of all memory handling


Solution 3:

Multiple option to work around

1- Change

   android:background="@drawable/wallpaper_2"

To

   android:background="@drawable/wallpaper"

numbers are not allowed in drawable names.

2- check image size if its too large replace it with a smaller sized image.

3- You can add android:largheap="true" in application tag in case image is large in resolution

4- Add a relative layout inside constraint layout or replace constraint layout with relative layout and then apply background


Solution 4:

firstly create all drawable file version for each dpi size

drawable-mdpi drawable-hdpi drawable-xhdpi drawable-xxhdpi drawable-xxxhdpi

then put your image by right click on res file and then chose image assert. after this step it will work i think


Solution 5:

On Ubuntu 16.04 paste the image into the workspace -> project name-> app-> src-> main -> res -> drawable. This worked for me instead only pasting directly into Android Studio 3.1.3 app -> res -> drawable


Post a Comment for "Background Image In Constraints Layout Does Not Work"