Expand background image completely in a RelativeLayout

1

I want an image to completely occupy the background of the entire screen and for that I use the attribute background of the RelativeLayout principal The layout corresponding to Activity is the following:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/fondoinicio"
    tools:context="com.kirolm.kmibilbideaklezo.MainActivity"
    android:paddingBottom="@dimen/activity_vertical_margin">
</RelativeLayout>

As can be seen in the following screenshot, there is a white vertical line to the right of the screen that I can not eliminate. The capture is made in preview of Android Studio . Specifically of a Nexus 5X with a screen of 1080x1920: 420 dpi , but the same thing happens with the different devices offered by Android Studio

I keep the image in different densities. These are the data:

  • hdpi (564x1001)
  • mdpi (376x667)
  • xhdpi (752x1334)
  • xxhdpi (1128x2001)
  • xxxhdpi (1504x2668)
asked by aldakur 30.05.2016 в 16:04
source

2 answers

0

The problems were in the image. The images were exported in different densities in Sketch , using plugin Sketch Android assets and apparently this plugin has an error. Add a vertical line the size of a pixel which is only visible when selecting the image.

I enclose an image with a lot of zoom so that the error in the export is appreciated.

Using another export plugin the problem has been solved.

    
answered by 31.05.2016 / 16:00
source
0

One option would be to add the image within a ImageView

and use the property:

android:scaleType="centerCrop"

or

 android:scaleType="fitXY"

    
answered by 30.05.2016 в 16:26