1

Я пытаюсь создать меню ресторана, имеющего следующий макет. поле товара и поле описания под ним сумма цены справа от товара. я попробовал все от использования list-view для каждой строки и имел вид списка, у которого элемент и описание было настроено на макет 2-х элементов, но у меня была проблема с синхронизацией других списков.Listview с настраиваемой структурой столбцов вложенных LinearLayouts

сейчас я попробовал иметь макет списка в качестве основного макета и добавить горизонтальный линейный макет с добавленными к нему текстовыми представлениями с равными весами. так как для первого столбца, который должен иметь 2 элемента, я использовал верную линейную компоновку и добавил текстовые представления к нему.

Я хочу установить вертикальный вес линейной компоновки, чтобы сказать 3, а остальная часть пунктов до 1. и внутри вертикальной линейной компоновки я хочу, чтобы текстовые представления заполняли ширину, но не превышали другие столбцы, и высоту для деформации содержимого, так как я загружаю описание элемента из db, который представляет собой довольно много строк.

Что я пробовал до сих пор, это только макет строки, который я добавляю в список-макет. на приведенном ниже рисунке показана проблема со списком.

enter image description here

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:gravity="left|center" 
    android:orientation="horizontal" 
    android:paddingBottom="6dip" 
    android:paddingTop="4dip" > 

    <LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:orientation="vertical" > 

     <TextView 
      android:id="@+id/text1_" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:text="TextView" /> 

     <TextView 
      android:id="@+id/text2_" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:text="TextView" /> 
    </LinearLayout> 

    <TextView android:id="@+id/FROM_CELL" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight="1"/> 

    <TextView android:id="@+id/TO_CELL" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight="1"/> 

    <TextView 
     android:id="@+id/TRAIN_CELL" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" /> 

</LinearLayout> 

ответ

1

использовать этот макет

<LinearLayout 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:orientation="vertical" > 

     <TextView 
      android:id="@+id/text1_" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:text="TextView" /> 

     <TextView 
      android:id="@+id/text2_" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="TextView" /> 
    </LinearLayout> 

    <TextView android:id="@+id/FROM_CELL" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
      /> 

    <TextView android:id="@+id/TO_CELL" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     /> 

    <TextView 
     android:id="@+id/TRAIN_CELL" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     /> 

</LinearLayout> 
+0

, что фиксированное вертикальное линейное расположение, но другие TextViews все еще перепутались –

+0

установки мин и максимальную ширину для TextViews в вертикальной линейной макете зафиксировано это для ответа –

Смежные вопросы