Suppose I have a background in my Activity
's root layout. I wish to place some buttons on the screen which always stay in the same place relative to the screen. How can I accomplish that?
I tried using dp
and sp
but if I test the layout in another screen it all falls apart. (So if it is OK in WVGA it is not working in QVGA. Am I doing something wrong?
This is my layout xml:
<?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:background="@drawable/menu_activity_bg" >
<Button
android:id="@+id/continueButton"
android:layout_width="110sp"
android:layout_height="30sp"
android:layout_marginLeft="100sp"
android:layout_marginTop="180sp"
android:background="@drawable/menu_activity_continue" />
<Button
android:id="@+id/newGameButton"
android:layout_width="130sp"
android:layout_height="35dp"
android:layout_marginLeft="90sp"
android:layout_marginTop="220sp"
android:background="@drawable/menu_activity_new_game" />
<!-- ... -->
</RelativeLayout>