2015-06-22 3 views
0

Я пытаюсь иметь один текстовый вид, который составляет 3/4 страницы и 1/4 страницы с баром оценки.Вес для Android textViews

К сожалению, когда длинный элемент помещается в мой TextView это pushses рейтинг бара ниже:

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#e5e5e5" 
    android:orientation="vertical" 

    android:id="@+id/switchOut"> 




     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="6dp" 
       android:layout_marginRight="6dp" 
       android:layout_marginTop="4dp" 
       android:layout_marginBottom="4dp" 
       android:orientation="vertical" 
       android:background="@drawable/bg_card"> 

       <!-- Card Contents go here --> 

       <ScrollView 
        android:id="@+id/SCROLLER_ID" 
        android:layout_width="fill_parent" 
        android:layout_height="0dp" 
        android:layout_weight="3" 
        android:scrollbars="vertical" 
        android:fillViewport="true"> 



       <TextView 
        android:id="@+id/reviewToRate" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:ems="10" 
        android:textSize="15sp" 
        android:padding="5dip" 

        ></TextView> 

       </ScrollView> 


      </LinearLayout > 

     </FrameLayout> 


    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="6dp" 
      android:layout_marginRight="6dp" 
      android:layout_marginTop="4dp" 
      android:layout_marginBottom="4dp" 
      android:orientation="vertical" 
      android:background="@drawable/bg_card"> 

      <!-- Card Contents go here --> 


      <RatingBar 
       android:id="@+id/reviewRatingBar" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:numStars="5" 
       android:stepSize="1.0" 
       android:rating="0" 


       /> 



     </LinearLayout > 

    </FrameLayout> 


</LinearLayout> 
+0

Вы должны удалить свой вид прокрутки. Это избыточно. – hungryghost

+0

Я вижу только один текстовый вид в вашем макете. Вы упомянули, что у вас их двое? –

ответ

1

Размеры макета должны быть на одном уровне иерархии в вашем макете. В основном, установите layout_weight="3" на свой первый FrameLayout (чтобы компенсировать второй FrameLayout с весом = 1) и удалите вес из ScrollView. Это должно выглядеть так:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#e5e5e5" 
    android:orientation="vertical" 
    android:id="@+id/switchOut"> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="3"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="6dp" 
      android:layout_marginRight="6dp" 
      android:layout_marginTop="4dp" 
      android:layout_marginBottom="4dp" 
      android:orientation="vertical" 
      android:background="@drawable/bg_card"> 

      <!-- Card Contents go here --> 

      <ScrollView 
       android:id="@+id/SCROLLER_ID" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:scrollbars="vertical" 
       android:fillViewport="true"> 

       <TextView 
        android:id="@+id/reviewToRate" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:ems="10" 
        android:textSize="15sp" 
        android:padding="5dip" /> 

      </ScrollView> 

     </LinearLayout > 

    </FrameLayout> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="6dp" 
      android:layout_marginRight="6dp" 
      android:layout_marginTop="4dp" 
      android:layout_marginBottom="4dp" 
      android:orientation="vertical" 
      android:background="@drawable/bg_card"> 

      <!-- Card Contents go here --> 

      <RatingBar 
       android:id="@+id/reviewRatingBar" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:numStars="5" 
       android:stepSize="1.0" 
       android:rating="0" /> 

     </LinearLayout > 

    </FrameLayout> 

</LinearLayout> 
0

Установите на max_width значение для этого TextView отрезать длинный текст, если это поведение, которое вы хотите. В противном случае, каково желаемое поведение?

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