-
Hai all I am new in android programming…..
For my application I am using image button and it successfully
installed on the device. But when I rotate the screen all the button
position get changed… and I need all the button placed at centre
of the screen…. And here is my code….<TextView android:id="@+id/testText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFCC99" android:textSize="24dp" /> <ImageButton android:id="@+id/up" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_marginRight="124dp" android:layout_marginTop="80dp" android:src="@drawable/up" /> <ImageButton android:id="@+id/left" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_below="@+id/up" android:layout_marginRight="200dp" android:layout_marginTop="150dp" android:src="@drawable/left" /> <ImageButton android:id="@+id/right" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_below="@+id/up" android:layout_marginRight="50dp" android:layout_marginTop="150dp" android:src="@drawable/right" /> <ImageButton android:id="@+id/down" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/up" android:layout_alignParentRight="true" android:layout_marginRight="124dp" android:layout_marginTop="80dp" android:src="@drawable/down" />Please help…………
Hai all I am new in android programming….. For my application I am using
Share
Set
android:gravitytocenter.The following layout will do for you:
There are other ways to do it.
1. Using relative layout
2. Using 2 layouts : 1 one for portrait and and 1 for landscape.