Android: imageView padding

I'm trying to add a picture via imageView. But I want to full fill my view with the image and also the imageView should fill the width of the screen. the image should begin and end at the screen edge's.

I used every xml attributes but no luck. This is the closest code to what I want.

<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/bck3"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<Button
    android:id="@+id/buttonStore"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:layout_alignBottom="@+id/imageView1"
    android:layout_alignParentRight="true"
    android:layout_marginRight="10dp"
    android:background="@drawable/store" />

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="100dp"
    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:src="@drawable/logo" />

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="fill_parent"
    android:layout_height="125dp"
    android:layout_marginTop="57dp"
    android:adjustViewBounds="true"
    android:scaleType="centerCrop"
    android:src="@drawable/ronaldo" />

Screenshot

It should be this What it should look like

Upvotes: 8

Views: 21188

Answers (2)

M.Bennett
M.Bennett

Reputation: 1029

android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"

Remove the padding on the parent layout, your imageview will then fill the entire width

Upvotes: 4

Chintan Soni
Chintan Soni

Reputation: 25267

try removing the following code from relative layout properties:

android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"

Upvotes: 6

Related Questions