Как сохранить этот макет равномерным по размерам экрана - PullRequest
0 голосов
/ 17 июля 2011

Я хотел бы сделать следующий макет, см. Рисунок ниже, где расположение представлений EditText остается правильно расположенным со стрелками.

Макет ниже, который я сделал, с RelativeLayout, использующим поля, но это не работает, когда кто-то устанавливает это приложение на телефон с разрешением 540x960, например HTC Sensations.

Заранее благодарен за помощь!

Действительный XHTML http://www.tricky.dds.nl/gui.png.

1 Ответ

1 голос
/ 17 июля 2011

Используйте комбинацию LinearLayout и RelativeLayout. С LinearLayout вы можете создавать на экране места, которые будут абсолютно одинаковыми на всех устройствах. Пусть ваш контейнер верхнего уровня будет LinearLayout. Например, чтобы создать вторую строку в изображении, на которое вы ссылаетесь, выполните что-то вроде этого:

<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>
...