Tony
Tony

Reputation: 3805

How to set ImageView right to the bottom?

I've got next template:

<?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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:background="@drawable/fight"
    tools:context="ru.net.babobka.FightActivity" >

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="150dp"
        android:layout_height="180dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/ken1" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="150dp"
        android:layout_height="190dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:src="@drawable/ryu1" />

</RelativeLayout>

The result is:

enter image description here

As you can see there is a space between image and bottom border. How to avoid that?

Upvotes: 0

Views: 72

Answers (3)

gegobyte
gegobyte

Reputation: 5565

Modify your layout like this:

<?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:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/fight"
android:layout_alignParentBottom="true"
tools:context="ru.net.babobka.FightActivity" >

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="150dp"
    android:layout_height="180dp"
    android:layout_alignParentLeft="true"
    android:src="@drawable/ken1" />

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="150dp"
    android:layout_height="190dp"
    android:layout_alignParentRight="true"
    android:src="@drawable/ryu1" />

</RelativeLayout>

Upvotes: 1

Naveen Tamrakar
Naveen Tamrakar

Reputation: 3339

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:gravity="bottom|left"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ken1" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:orientation="vertical" 
    android:gravity="bottom|right">

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ryu1" />
</LinearLayout>

Upvotes: 1

Christoffer
Christoffer

Reputation: 7787

You relative layout has padding. That means it will push all content inwards. Remove the padding.

Upvotes: 1

Related Questions