1

This is how it shows---

enter image description here

The XML is as below

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="178dp"
    android:orientation="vertical"
    android:background="@mipmap/background_poly"
    android:scaleType="fitXY"
    android:weightSum="1">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:orientation="vertical"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true">

    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:textColor="#ffffff"
        android:text="Xxxxx Xxxx"
        android:textSize="14sp"
        android:textStyle="bold"

        />

    <TextView
        android:id="@+id/email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#ffffff"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="5dp"
        android:text="xxxxxxxx@xxxx.com"
        android:textSize="14sp"
        android:textStyle="normal"

        />
</LinearLayout>

<de.hdodenhof.circleimageview.CircleImageView
    android:layout_width="70dp"
    android:layout_height="70dp"
    android:src="@mipmap/aka"
    android:layout_marginLeft="16dp"
    android:layout_marginTop="38dp"
    android:id="@+id/circleView"
    />
</RelativeLayout>

I want the background image to fill the relative layout fully.

I tried using the scaleType to **fitXY , center_crop ** etc

I have even tried adding a ImageView into the RelativeLayout and set its as below

<ImageView 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerInParent="true"
        android:scaleType="centerCrop"
        android:src="@drawable/background" />

it did not work...

Help is appreciated, thanks...

Boopathi T
  • 117
  • 1
  • 12

4 Answers4

1

Firstly, don't use mipmap folders for any icons or images other than the Launcher Icon. Place all your other icons or images inside their respective drawable folders.

Secondly, I have tried your code and I replaced your background_poly image with a color and it filled the entire Relative Layout. Maybe, your image contains a padding inside it which does not allow it to cover the entire layout. Edit your image in some image editing tool like Photoshop etc.

Varun Kumar
  • 1,241
  • 1
  • 9
  • 18
  • then how to import an image in android studio 1.5 into the drawable folder. When importing as New->Image Asses->Launcher Icon it falls in mipmap folder and if importing with New->Image Asset->Action Bar or Tab Icon it falls on drawable but a only blank white image is imported and i don't think so i should use New->Image Asset->Notification icon. – Boopathi T Mar 22 '16 at 16:46
  • Your launcher icon should fall into mipmap folder only. But look at your xml code above, background of relative layout is present in mipmap folder. It should be present in the drawable folder. – Varun Kumar Mar 22 '16 at 16:55
  • you are correct. But how to import an image into drawable folder...? – Boopathi T Mar 22 '16 at 17:04
  • If you have the image on your laptop or computer, just copy it and paste it inside the drawable folders. Initially, drawable folders are not added by default. You have to add them to the res folder, each drawable folder targeting a different density package of the Android system – Varun Kumar Mar 23 '16 at 02:44
  • Like drawable-ldli, drawable-mdpi etc. and then add the image files with specifications depending on the density of the each package. – Varun Kumar Mar 23 '16 at 02:46
  • For e.g., if you want to add an image say image to your project. You'll need to create different copies of image varying in size (pixels) and memory (size on disk) according to the targeting package for each image file. – Varun Kumar Mar 23 '16 at 02:48
  • For more info, visit the following links: – Varun Kumar Mar 23 '16 at 02:50
  • http://stackoverflow.com/questions/29047902/how-to-add-an-image-to-the-drawable-folder-in-android-studio – Varun Kumar Mar 23 '16 at 02:51
  • If you still have any queries, feel free to ask. – Varun Kumar Mar 23 '16 at 02:53
1

It's your background image problem. because background image contain transparancy at the border. remove transparant shade effect from border or change image, your problem will solve.

Mehul Santoki
  • 1,208
  • 1
  • 12
  • 25
  • i think when importing images through android studio it just add transparent border to it. But I want images to be imported into drawable from android studio. Is that possible?? – Boopathi T Mar 22 '16 at 17:02
  • Android studio can not change image effects. You can imaport images into drawable just copy paste images in drawable – Mehul Santoki Mar 23 '16 at 10:24
0

mipmap basically use for the app icon. You need to put your image resource to drawable folder and change your relative layout height to match parent

android:layout_height="match_parent"
SANAT
  • 8,489
  • 55
  • 66
0

First chage the layoutHeight to android:layout_height="match_parent"

then change the image scaleType to android:scaleType="fitXY"

And also remove the transparency from your image.

HassanUsman
  • 1,787
  • 1
  • 20
  • 38