Why does my layout repeats in device but looks fine on emulator when an image is added in a Relative Layout?

Posted by Honey H on Stack Overflow See other posts from Stack Overflow or by Honey H
Published on 2012-10-16T03:57:46Z Indexed on 2012/10/16 5:03 UTC
Read the original article Hit count: 835

let me try to explain clearly with what I want here. I have a RelativeLayout that contains a header image and the content below it.

Now, when i have a header image and a list view below it, the page fits the screen in the device properly, the layout does not repeat.

But when I place an image below the header image, the layout repeats in the device. Meaning i could see 2 header images in the device. Some page, I could see half of the header image that is not supposed to be there (repeated header image). However, in emulator, all the pages looks fine and fit the screen nicely.

I tried changing to LinearLayout, RelativeLayout inside LinearLayout, Relative Layout, it gave me the same outcome. I hope someone could tell me why this happened. Thanks.

Attached is my layout.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/bg" >

<ImageView
android:id="@+id/header"
android:contentDescription="@string/image"
android:src= "@drawable/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="centerCrop"/>

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical" >

<ImageView
android:id="@+id/journal"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_alignTop="@+id/kick"
android:adjustViewBounds="true"
android:contentDescription="@string/image"
android:padding="10dp"
android:src="@drawable/favourite_journal" />

<ImageView
android:id="@+id/kick"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_toRightOf="@+id/journal"
android:layout_below="@+id/header"
android:adjustViewBounds="true"
android:contentDescription="@string/image"
android:padding="10dp"
android:src="@drawable/favourite_kick" />

<ImageView
android:id="@+id/labour"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_below="@+id/journal"
android:layout_alignLeft="@+id/journal"
android:adjustViewBounds="true"
android:contentDescription="@string/image"
android:padding="10dp"
android:src="@drawable/favourite_labour" />

<ImageView
android:id="@+id/share"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_below="@+id/kick"
android:layout_alignLeft="@+id/kick"
android:adjustViewBounds="true"
android:contentDescription="@string/image"
android:padding="10dp"
android:src="@drawable/favourite_share" />
</RelativeLayout>
</RelativeLayout>

© Stack Overflow or respective owner

Related posts about android

Related posts about android-layout