Yayo28
Yayo28

Reputation: 342

Relative layout not putting button in place

im using this code;

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:text="Button" />

</RelativeLayout>

and for some reason this is not working in the emulator with 540x960. The button appear in the middle of the emulator.

In my droid2 it works correctly.

enter image description here

the left picture show how it works in my droid 2 cellphone, and right side show how is working in the HTC sensationXe emulator

Upvotes: 1

Views: 217

Answers (4)

TanuPriya
TanuPriya

Reputation: 13

Edit your XML by this and it will work.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:gravity="bottom"
        android:text="Button" />

</RelativeLayout>

Upvotes: 0

Yayo28
Yayo28

Reputation: 342

I Already found the answer of the problem. i was compiling my app as anddroid 1.5, now i added this to the manifest

<uses-sdk android:minSdkVersion="3"
     android:targetSdkVersion="4" />

and i compile to android 1.6

now the is in the place it has to be

Upvotes: 1

user994886
user994886

Reputation: 444

Orientation attribute does not work for Relative Layouts. Try following

<TextView
    android:id="@+id/helloid"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello" />

<Button
    android:id="@+id/button1"
    android:layout_below="@id/helloid"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:text="Button" />

Upvotes: 0

Cata
Cata

Reputation: 11211

You have to set an anchor point to your TextView.. try to align the text view in the left of the button or in its right side and the problem should disappear.

Upvotes: 0

Related Questions