2012-03-05 2 views
4

Я хотел бы узнать лучший способ использования линейного макета или макета таблицы для проектирования прилагаемого экрана Android. enter image description hereandroid - Использование линейного или табличного макета

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

+1

[Относительная схема] (http://developer.android.com/reference/android/widget/RelativeLayout.html) - ваш друг. – bschultz

ответ

1

Использовать 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> 
Смежные вопросы