Android - Использование линейного или табличного макета - PullRequest
4 голосов
/ 06 марта 2012

Я хотел бы знать, как лучше всего использовать Linear Layout или Table Layout для проектирования подключенного экрана Android.enter image description here

Я использую линейный макет в качестве основного макета, а затем добавляю в него сублинейные макеты и макеты таблиц.Это лучший способ сделать ???

1 Ответ

1 голос
/ 06 марта 2012

Использовать RelativeLayout или GridLayout (только ICS и выше).

Это должно помочь вам начать. Это не совсем то, что вы хотите, но, надеюсь, это близко. Я не тестировал код, поэтому даже не знаю, компилируется ли он. Хотя не должно быть слишком далеко от окончательного кода. :)

<RelativeLayout>
  <!-- Image, may want to size this as a square using dp pixels say, 64dpx64dp -->
  <ImageView android:id="@+id/PhotoImageView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" />

  <!-- TextViews at the right of the image. Stacked, caution this might end up being taller than the ImageView itself. -->
  <TextView android:id="@+id/PersonNameTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_toRightOf="@id/PhotoImageView" />
  <TextView android:id="@+id/TitleTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_toRightOf="@id/PhotoImageView" android:layout_below="@id/PersonNameTextView" />

  <!-- Stacked TextViews below, you can split this out to side by side TextViews but that's more work. -->
  <TextView android:id="@+id/PhoneTextView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/PhotoImageView" />
  <TextView android:id="@+id/EmailTextView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/PhoneTextView" />

  <!-- Delete button placed at the bottom. -->
  <Button android:id="@+id/DeleteButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" />
</RelativeLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...