2015-04-13 2 views
0

Я не вижу, чтобы найти способ предотвратить отсечение самого нижнего LinearLayout в списке прокрутки. Я попытался добавить weightsum и обеспечить, чтобы раздел Notes (@ + id/etNotes) растягивался и заполнял экран в зависимости от высоты устройства, однако он, кажется, отключается (@ + id/bPhot) и (@ + id/bHelp) Как мы можем обеспечить отображение всех элементов даже на маленьких экранах?Перекрытие LinearLayouts в ScrollView

Любая помощь с благодарностью. Спасибо

<ScrollView 
    android:id="@+id/svMain" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="horizontal" > 

       <LinearLayout 
         android:layout_width="match_parent" 
         android:orientation="vertical" 
         android:layout_height="match_parent" 
         android:gravity="center_vertical">   

          <TextView 
           android:id="@+id/tvDetails" 
           android:layout_width="match_parent" 
           android:layout_height="wrap_content" 
           android:background="@color/yellow" 
           android:clickable="true" 
           android:padding="10dp" 
           android:text="TextView" 
           android:textSize="@dimen/seventeen" /> 

          <LinearLayout 
           android:layout_width="match_parent" 
           android:layout_height="10dp" 
           android:orientation="vertical" > 
          </LinearLayout> 

          <RadioGroup 
           android:id="@+id/rgStatus" 
           android:layout_width="fill_parent" 
           android:layout_height="wrap_content" 
           android:layout_gravity="right" 
           android:layout_marginLeft="@dimen/activity_horizontal_margin" > 

           <RadioButton 
            android:id="@+id/radio0" 
            android:layout_width="match_parent" 
            android:layout_height="46dp" 
            android:checked="false" 
            android:text="Option1" 
            android:textSize="@dimen/twentysize" /> 

           <RadioButton 
            android:id="@+id/radio1" 
            android:layout_width="match_parent" 
            android:layout_height="48dp" 
            android:text="Option2" 
            android:textSize="@dimen/twentysize" /> 

           <RadioButton 
            android:id="@+id/radio2" 
            android:layout_width="match_parent" 
            android:layout_height="46dp" 
            android:checked="true" 
            android:text="Option3" 
            android:textSize="@dimen/twentysize" /> 

          </RadioGroup> 

          <LinearLayout 
           android:layout_width="match_parent" 
           android:layout_height="10dp" 
           android:orientation="vertical" > 
          </LinearLayout> 

            <LinearLayout 
                android:layout_width="match_parent" 
                android:layout_height="fill_parent" 
                android:background="@color/whitewhite" 
                android:weightSum="5"      
                android:orientation="vertical"> 

               <LinearLayout 
                android:layout_width="match_parent" 
                android:layout_height="fill_parent" 
                android:layout_weight="0.5" 
                android:background="@color/whitewhite" 
                android:padding="10dp" > 

               <EditText 
                android:id="@+id/etNotes" 
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent" 
                android:background="@color/whitewhite" 
                android:ems="10" 
                android:gravity="top" 
                android:hint="Notes (optional)" 
                android:inputType="textMultiLine" 
                android:padding="5dp" /> 

               </LinearLayout> 

               <LinearLayout 
                android:layout_width="match_parent" 
                android:layout_height="fill_parent" 
                android:layout_weight="2" 
                android:background="@color/whitewhite" 
                android:gravity="bottom" 
                android:orientation="horizontal" 
                android:padding="8dp" > 

                <Button 
                 android:id="@+id/bPhoto" 
                 android:layout_width="45dp" 
                 android:layout_height="45dp" 
                 android:layout_weight=".02" 
                 android:background="@drawable/camera" 
                 android:gravity="left|center_vertical"/> 

                <Button 
                 android:id="@+id/bHelp" 
                 android:layout_width="wrap_content" 
                 android:layout_height="wrap_content" 
                 android:layout_weight="2.5" 
                 android:background="@null" 
                 android:gravity="right|center_vertical" 
                 android:paddingRight="@dimen/sevendp" 
                 android:text="Check List" 
                 android:textColor="@color/holobluelight" 
                 android:textSize="@dimen/sixteen" /> 

               </LinearLayout> 




            </LinearLayout> 
       </LinearLayout> 
     </LinearLayout> 

</ScrollView> 
+0

Попробуйте установить 'android: layout_height =" wrap_content "' для родительского 'LinearLayout'. – Ircover

ответ

1

Здесь ваш полный макет вновь: Эта часть была изменена:

OLD:

 <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="fill_parent" 
       android:background="@color/whitewhite" 
       android:weightSum="5" 
       android:orientation="vertical"> 

      <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="fill_parent" 
        android:layout_weight="0.5" 
        android:background="@color/whitewhite" 
        android:padding="10dp" > 

       <EditText 
         android:id="@+id/etNotes" 

NEW

 <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="fill_parent" 
       android:background="@color/whitewhite" 
       android:orientation="vertical"> 

      <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_weight="1" 
        android:background="@color/whitewhite" 
        android:padding="10dp" > 

       <EditText 
         android:id="@+id/etNotes" 

ПОЛНОЕ

<ScrollView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/svMain" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fillViewport="true" > 

    <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="horizontal" > 

     <LinearLayout 
       android:layout_width="match_parent" 
       android:orientation="vertical" 
       android:layout_height="match_parent" 
       android:gravity="center_vertical"> 

      <TextView 
        android:id="@+id/tvDetails" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:background="@color/yellow" 
        android:clickable="true" 
        android:padding="10dp" 
        android:text="TextView" 
        android:textSize="@dimen/seventeen" /> 

      <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="10dp" 
        android:orientation="vertical" > 
      </LinearLayout> 

      <RadioGroup 
        android:id="@+id/rgStatus" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="right" 
        android:layout_marginLeft="@dimen/activity_horizontal_margin" > 

       <RadioButton 
         android:id="@+id/radio0" 
         android:layout_width="match_parent" 
         android:layout_height="46dp" 
         android:checked="false" 
         android:text="Option1" 
         android:textSize="@dimen/twentysize" /> 

       <RadioButton 
         android:id="@+id/radio1" 
         android:layout_width="match_parent" 
         android:layout_height="48dp" 
         android:text="Option2" 
         android:textSize="@dimen/twentysize" /> 

       <RadioButton 
         android:id="@+id/radio2" 
         android:layout_width="match_parent" 
         android:layout_height="46dp" 
         android:checked="true" 
         android:text="Option3" 
         android:textSize="@dimen/twentysize" /> 

      </RadioGroup> 

      <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="10dp" 
        android:orientation="vertical" > 
      </LinearLayout> 

      <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="fill_parent" 
        android:background="@color/whitewhite" 
        android:orientation="vertical"> 

       <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="0dp" 
         android:layout_weight="1" 
         android:background="@color/whitewhite" 
         android:padding="10dp" > 

        <EditText 
          android:id="@+id/etNotes" 
          android:layout_width="fill_parent" 
          android:layout_height="fill_parent" 
          android:background="@color/whitewhite" 
          android:ems="10" 
          android:gravity="top" 
          android:hint="Notes (optional)" 
          android:inputType="textMultiLine" 
          android:padding="5dp" /> 

       </LinearLayout> 

       <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:background="@color/whitewhite" 
         android:gravity="bottom" 
         android:orientation="horizontal" 
         android:padding="8dp" > 

        <Button 
          android:id="@+id/bPhoto" 
          android:layout_width="45dp" 
          android:layout_height="45dp" 
          android:layout_weight=".02" 
          android:background="@drawable/camera" 
          android:gravity="left|center_vertical"/> 

        <Button 
          android:id="@+id/bHelp" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_weight="2.5" 
          android:background="@null" 
          android:gravity="right|center_vertical" 
          android:paddingRight="@dimen/sevendp" 
          android:text="Check List" 
          android:textColor="@color/holobluelight" 
          android:textSize="@dimen/sixteen" /> 

       </LinearLayout> 




      </LinearLayout> 
     </LinearLayout> 
    </LinearLayout> 

</ScrollView> 
+0

Ваше лучшее! Это сработало отлично! – oo33

+0

Да, извините, я забыл проверить это! благодаря – oo33

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