On my graphical layout in Eclipse, the EditView, TextView, and button are where I want them to be. But when I run them on my phone, they are moved to a different location. Can someone help me keep them where I want them to be?
Here’s my code:
<?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="match_parent"
android:background="@drawable/backgroundhdpi" >
<EditText
android:id="@+id/bill"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="100dp"
android:ems="10"
android:inputType="phone"
android:text="Enter Your Bill"
android:textSize="18dip" />
<Button
android:id="@+id/calculateTip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/bill"
android:layout_alignParentBottom="true"
android:layout_marginBottom="40dp"
android:layout_marginLeft="15dp"
android:text="Calculate" />
<TextView
android:id="@+id/tipOwed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/bill"
android:layout_centerHorizontal="true"
android:layout_marginBottom="123dp"
android:scrollHorizontally="false"
android:text="Time to Tip!"
android:textColor="#2c6f37"
android:textSize="35dip"
android:textStyle="bold" />
</RelativeLayout>
If I may ask, what type/unit of phone do you try to run your code? The layout of the program on a user’s view of point is, at times, dependent to the screen of the phone they are using.
Example:
You run the app with an Galaxy S2 emulator, and you try to run it in a Galaxy Y. With the difference of the screen resolution of the two, you could notice the difference between the space that the layout could occupy.
Also, are you placing the images that are being used in your layout in a single drawable folder? Like for example, drawable-hdpi?
Placing images that will be later on used by your layout in different drawable folders could affect directly the size or resolution of the image.