2017-04-26 4 views
0

고정 레이아웃을 유지하면서 여러 줄로 된 텍스트 뷰를 구현하고 싶습니다. 이것은 예상 출력 화면 image 1입니다.레이아웃을 고정한 상태에서 여러 줄로 된 텍스트 뷰

그리고이 출력은 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> 

maxLine을 설정하고 weight 속성을 할당해도 레이아웃이 고정되지 않습니다. 그리고 일부는 "Out of Stock"이미지 2와 비슷합니다. 어떻게이 문제를 해결할 수 있습니까?

답변

0

가중치를 사용하려면 txt_product_cost 높이를 0dp로 바꿉니다. 처음있는 LinearLayout에 TextViwes에 대한 layout_weight를 = "0.20" 및 안드로이드를 변경 :

<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"/> 
문제가 해결됩니다

0

당신은 안드로이드를 제거하려고한다 wrap_content에을 layout_height

0

여기에서는 layout_weight를 신뢰할 수 없습니다. layout_height를 "wrap_content"로 설정하십시오.

관련 문제