2015-01-24 7 views
1

мой взгляд содержит ScrolView с несколькими видами внутри, а другой LinearLayout с идентификатором «bottom_view». проблема заключается в том, что если ScrolView содержит много видов, он скрывает «bottom_view» LinearLayout.android - ScrollView заполняет весь экран

это мой код:

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/white" 
    tools:context=".MainActivity"> 

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

     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:padding="10dp" 
      android:background="@drawable/customborder" 

      tools:context=".MainActivity"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/dialog_text_layout_name" 
       > 
       <TextView 
        android:id="@+id/dialog_text_product_name" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textStyle="bold" 
        android:gravity="center" 
        android:textSize="20sp" 
        android:visibility="visible" 
        android:adjustViewBounds="true" 
        android:text="name" /> 
      </LinearLayout> 

      <FrameLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/dialog_text_layout_name" 

       > 

       <com.parse.ParseImageView 
        android:id="@+id/img_row_logo" 
        android:layout_width="wrap_content" 
        android:layout_height="200sp" 
        android:layout_gravity="center" 

        android:src="@drawable/no_image" 
        android:adjustViewBounds="true" 
        android:visibility="visible"> 
       </com.parse.ParseImageView> 

       <TextView 
        android:id="@+id/price" 
        android:layout_gravity="left|center_vertical" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:paddingLeft="24sp" 
        android:textSize="20sp" 
        android:text="מחיר" 
        android:textColor="#ffffff" 
        android:background="#FF8000" 

        > 
       </TextView> 
      </FrameLayout> 
      <TextView 
       android:id="@+id/dialog_text_product_desc" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="50dp" 
       android:gravity="start" 
       android:visibility="gone" 
       android:textSize="20sp" 
       android:text="אין תיאור" 
       /> 
      <TextView 
       android:id="@+id/dialog_text_business_name" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="end" 
       android:text="מחסני חשמל" 
       android:textColor="#FF8000" 
       android:textSize="20sp"/> 


      <TextView 
       android:id="@+id/dialog_address" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="יפו 30 ירושלים" 
       android:layout_gravity="end" 
       android:layout_marginTop="20sp" 
       android:textSize="20sp"/> 

      <LinearLayout 
       android:gravity="right" 
       android:layout_width="match_parent" 
       android:layout_height="45dp" 
       android:layout_marginTop="15sp" 
       android:orientation = "horizontal" > 
       <TextView 
        android:id="@+id/dialog_telephone_text" 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" 
        android:text="03-1234567" 
        android:textSize="20sp"/> 
       <TextView 
        android:id="@+id/dialog_telephone" 
        android:layout_width="wrap_content" 
        android:layout_height="match_parent" 
        android:textSize="20sp" 
        android:text="טלפון: "/> 

      </LinearLayout> 

      <LinearLayout 
       android:gravity="right" 
       android:layout_width="match_parent" 
       android:layout_height="45sp" 
       android:orientation = "horizontal" > 
       <TextView 
        android:id="@+id/dialog_text_distance" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="מרחק לא ידוע" 
        android:textSize="20sp"/> 
      </LinearLayout> 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:orientation = "vertical" > 
       <TextView 
        android:id="@+id/dialog_open_hours" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:singleLine="true" 
        android:layout_gravity="end" 
        android:text="שעות פתיחה" 
        android:textSize="20sp"/> 
       <TextView 
        android:id="@+id/dialog_open_hours_text" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="אין מידע" 
        android:textSize="20sp"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="אין מידע" 
        android:textSize="20sp"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="אין מידע" 
        android:textSize="20sp"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="אין מידע" 
        android:textSize="20sp"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="אין מידע" 
        android:textSize="20sp"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="אין מידע" 
        android:textSize="20sp"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="אין מידע" 
        android:textSize="20sp"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="אין מידע" 
        android:textSize="20sp"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="אין מידע" 
        android:textSize="20sp"/> 
       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="אין מידע" 
        android:textSize="20sp"/> 

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

    <LinearLayout 
    android:id="@+id/bottom_view" 
    android:background="@drawable/my_black" 
    android:layout_width="match_parent" 
    android:layout_height="25dp" 
    android:orientation = "horizontal" 
    android:layout_alignParentBottom="true"> 

    <ImageView 
     android:layout_gravity="left" 
     android:id="@+id/phone" 
     android:layout_width="0dp" 
     android:layout_weight= "1" 
     android:layout_height="match_parent" 
     android:src="@drawable/phone" 
     android:visibility="visible"> 
    </ImageView> 

    <ImageView 
     android:id="@+id/share" 
     android:layout_width="0dp" 
     android:layout_weight= "1" 
     android:layout_height="match_parent" 
     android:src="@drawable/share_btn" 
     android:visibility="visible"> 
    </ImageView> 

    <ImageView 
     android:id="@+id/images" 
     android:layout_width="0dp" 
     android:layout_weight= "1" 
     android:layout_height="match_parent" 
     android:src="@drawable/images" 
     android:visibility="visible"> 
    </ImageView> 

    <ImageView 
     android:id="@+id/home" 
     android:layout_width="0dp" 
     android:layout_weight= "1" 
     android:layout_height="match_parent" 
     android:src="@drawable/home_con_white" 
     android:visibility="visible"> 
    </ImageView> 

    </LinearLayout> 
</LinearLayout> 

спасибо!

ответ

1

Изменение высоты ScrollView макет:

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

Проблема заключалась в том, что LinearLayout внутри ScrollView имел match_parent высоту и заставить ScrollView взять весь экран.

0

ScrollView и макет с кнопкой "отменить" ниже

LayoutParams scrollViewLayoutParams = new FrameLayout.LayoutParams(
        LinearLayout.LayoutParams.MATCH_PARENT, 
        LinearLayout.LayoutParams.WRAP_CONTENT 
      ); 
scrollViewLayoutParams.setMargins(0, 
          convertToDp(10), 
          0, 
          convertToDp(50)); // 50dp - place for button 
scrollView.setLayoutParams(scrollViewLayoutParams); 
parentView = (ViewGroup) scrollView.getParent(); // parent FrameLayout 
parentView.addView(cancelButtonLayout); 

Scrollview

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/scroll_view" 
    android:overScrollMode="ifContentScrolls"> 
    <LinearLayout 
     android:id="@+id/container" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:paddingStart="20dp" 
     android:paddingEnd="20dp" 
     android:orientation="vertical"> 
    </LinearLayout> 
</ScrollView> 

"отменить" расположение кнопок

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentEnd="true" 
    > 
       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:id="@+id/cancel_button" 
        android:text="@android:string/cancel" 
        android:layout_gravity="end" 
        style="?android:attr/buttonBarNegativeButtonStyle" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentEnd="true" 
        /> 
</RelativeLayout> 

screenshot

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