2017-04-26 3 views
0

Ich möchte mehrzeilige Textansicht implementieren, die ein festes Layout behält. Dies ist der erwartete Ausgabebildschirm image 1.Mehrzeilige Textansicht, während das Layout fixiert bleibt

Und das ist Ausgabe ich bekomme image2.

<LinearLayout 
    android:id="@+id/layout_product_desc" 
    android:layout_width="0dp" 
    android:layout_weight="0.75" 
    android:layout_height="match_parent" 
    android:padding="4dp" 
    android:gravity="center" 
    android:weightSum="1" 
    android:orientation="vertical"> 
    <LinearLayout 
     android:layout_weight="0.90" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:orientation="vertical" 
     android:weightSum="1"> 

     <TextView 
      android:id="@+id/txt_product_title" 
      style="@style/Appio.Text.Dark.Normal" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_gravity="start" 
      android:layout_weight="0.40" 
      android:maxLines="2"/> 
     <TextView 
      android:id="@+id/txt_product_subtitle_or_model" 
      style="@style/Appio.Text.Dark.Small" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_gravity="start" 
      android:layout_weight="0.20" 
      android:maxLines="1"/> 
     <TextView 
      android:id="@+id/txt_product_short_description" 
      style="@style/Appio.Text.Dark.Small" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_gravity="start" 
      android:layout_weight="0.20" 
      android:maxLines="1"/> 
     <TextView 
      android:id="@+id/txt_product_availability" 
      style="@style/Appio.Text.Dark.Small" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_gravity="start" 
      android:layout_weight="0.20" 
      android:maxLines="1"/> 
    </LinearLayout> 
    <TextView 
     android:id="@+id/txt_product_cost" 
     style="@style/Appio.Text.Primary.Normal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="start" 
     android:layout_weight="0.10" 
     android:maxLines="1"/> 
</LinearLayout> 

Obwohl ich MaxLine und Weight-Eigenschaft zuweisen, blieb das Layout nicht behoben. Und einige von "Ausverkauft" zeigen wie in Bild 2. Wie löse ich dieses Problem?

Antwort

0

Ersetzen Sie die txt_product_cost Höhe auf 0dp, wenn Sie Gewichte verwenden möchten.

<TextView 
    android:id="@+id/txt_product_cost" 
    style="@style/Appio.Text.Primary.Normal" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_gravity="start" 
    android:layout_weight="0.10" 
    android:maxLines="1"/> 

, dass Ihr Problem

0

beheben sollten Sie sollten versuchen, zu entfernen android: layout_weight = "0.20" für die TextViwes im ersten Linearlayout und Ändern android: layout_height-wrap_content

0

Sie können sich hier nicht auf layout_weight verlassen. Setzen Sie layout_height auf "wrap_content"

Verwandte Themen