How to keep this layout uniform across screen sizes
I would like to make the following layout, see picture below, where the place of the EditText views stay correct positioned w.r.t. the arrows.
The layout below I've made with a RelativeLayout making use of margins, but this doesn't work when som开发者_如何学运维eone installs this app on a 540x960 resolution phone like the HTC sensations.
Thanks in advance for your help!
Valid XHTML http://www.tricky.dds.nl/gui.png.
Use a combination of LinearLayout and RelativeLayout. With LinearLayout you can create spaces on the screen that will be exactly alike on all devices. Let your top level container be a LinearLayout. For instance, to create the second row in the image you reffered to, do something like this:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
</TextView>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
</TextView>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
</RelativeLayout>
</LinearLayout>
精彩评论