ANDROID STUDIO - background layout image turns white

Asked

Viewed 139 times

0

Good, currently I am developing a project in android studio and I am here with a problem. In one of the layouts, you set an image as the background, but when you execute it, it turns white. The image has the dimensions appropriate to the layout in question (5.5), is in the appropriate folder (drawables) and is set in the xml file but still only appears in the layout in android studio, when running on the mobile phone turns white.

Code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:animateLayoutChanges="true"
    android:background="@drawable/fundo"
    android:orientation="vertical"
    tools:context=".MainActivity">


    <ImageView
        android:id="@+id/logo"
        android:layout_width="wrap_content"
        android:layout_height="300dp"
        android:layout_marginTop="200dp"
        app:srcCompat="@drawable/logo_branco" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="450dp"
        android:fontFamily="@font/advent_pro_thin"
        android:text="O automóvel ideal para si!"
        android:textColor="#E76C00"
        android:textSize="20sp"
        android:textStyle="bold" />

</RelativeLayout>

1 answer

0

What has happened to me has been to use a wrong format for a certain function, which ended up giving error. You should save the image you want to use in different formats in drawable ex: . jpeg,.png... and try to compile.

  • Good friend, first of all thank you for answering. At the time I was able to solve the problem by changing its image for another since I have the idea that the problem was the resolution of the same... When compiling on my mobile phone the same probably did not support this resolution so the white screen.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.