Expand background image completely in a RelativeLayout

I want an image to completely occupy the background of the entire screen and for this I use the background attribute of the main RelativeLayout The layout corresponding to the Activity is as follows:

<?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 shown in the following screenshot, there is a white vertical line to the right of the screen that I cannot remove. The capture is done in the preview of Android Studio. Specifically of a Nexus 5X with a screen of 1080x1920: 420 dpi, but the same happens with the different devices offered Android Studio

enter the description of the image here

The image is stored in different densities. Here are the data:

  • hdpi (564x1001)
  • mdpi (376x667)
  • xhdpi (752x1334)
  • xxhdpi (1128x2001)
  • xxxhdpi (1504x2668)
 1
Author: aldakur, 2016-05-30

2 answers

One option would be to add the image inside a ImageView

And use property:

android:scaleType="centerCrop"

enter the description of the image here

Or

 android:scaleType="fitXY"

enter the description of the image here

 0
Author: Jorgesys, 2016-05-30 14:26:48

The problem was in the picture. The images were exported in different densities in Sketch, using the plugin Sketch Android assets and apparently this plugin has an error. Adds a vertical line the size of a pixel which is only visible when you select the image.

I attach image with a lot of zoom to appreciate the error in the export.

enter the description of the image here

Using another export plugin the problem has been solved.

 0
Author: aldakur, 2016-05-31 14:00:54