2016-08-08 169 views
1

我有一个内部布局布局,里面有一个布局,它们都在一个滚动视图内。我试图让整个屏幕滚动列表视图内的内容,然后在该列表视图下的文字浏览。我得到整个列表视图来填充和正确显示,但所有textviews的底部布局不显示。布局不显示在滚动视图内的列表视图

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <include 
     android:id="@+id/app_bar" 
     layout="@layout/app_bar" /> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fillViewport="true" 
     android:layout_below="@id/app_bar"> 

      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:padding="10dp"> 

       <ImageView 
        android:id="@+id/bannerReceiptLogo" 
        android:layout_width="170dp" 
        android:layout_height="75dp" 
        android:layout_centerHorizontal="true" 
        android:layout_marginTop="30dp" 
        android:background="@drawable/img_logo_receipt_cub" /> 

       <TextView 
        android:id="@+id/bannerAddressHeader" 
        android:layout_width="200dp" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/bannerReceiptLogo" 
        android:layout_centerHorizontal="true" 
        android:layout_marginTop="10dp" 
        android:text="@string/storeHeader" 
        android:textAlignment="center" 
        android:textSize="18sp" /> 

       <ListView 
        android:id="@+id/fullEReceiptListView" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/bannerAddressHeader" 
        android:layout_marginTop="10dp" 
        android:scrollbars="none"/> 

       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:layout_below="@id/fullEReceiptListView" 
        android:layout_weight="1"> 
       <View 
        android:id="@+id/totalDivider" 
        android:layout_width="match_parent" 
        android:layout_height="3dp" 
        android:background="@color/colorGrey" 
        /> 

       <TextView 
        android:id="@+id/txtSubTotal" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="SUBTOTAL" 
        android:textSize="20sp" 
        android:layout_below="@+id/totalDivider"/> 

       <TextView 
        android:id="@+id/txtSubTotalFinal" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="$13.58" 
        android:layout_alignParentRight="true" 
        android:textSize="20dp" 
        android:layout_below="@+id/totalDivider"/> 

       <TextView 
        android:id="@+id/txtTaxText" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="TAX" 
        android:textSize="20sp" 
        android:layout_below="@+id/txtSubTotal"/> 

       <TextView 
        android:id="@+id/txtTaxTotal" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="$0.80" 
        android:layout_alignParentRight="true" 
        android:textSize="20dp" 
        android:layout_below="@+id/txtSubTotalFinal"/> 

       <TextView 
        android:id="@+id/txtCompleteTotal" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="TOTAL" 
        android:textSize="20sp" 
        android:layout_below="@+id/txtTaxText"/> 

       <TextView 
        android:id="@+id/txtCompleteTotalNumber" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="$14.38" 
        android:layout_alignParentRight="true" 
        android:textSize="20dp" 
        android:layout_below="@+id/txtTaxText"/> 
       </RelativeLayout> 
      </RelativeLayout> 
    </ScrollView> 
</RelativeLayout> 

回答

0

不要把ListViewScrollViewListView是一个已经可以滚动的小部件。请参阅支持库中的NestedScrollView

+0

那么,NestedScrollView不允许布局有2个滚动条?我想让整个视图滚动为1个单位。 –

0

如果设置了ListView高度wrap_content高度将有高度相称的所有项目。这样,下面的内容将被推开。

但是,Android对嵌套滚动没有很好的支持,这被认为是不好的做法。这样,你的ListView将不具备原生滚动功能,并需要一些破解按预期工作。

一个更好的解决方法是使用NestedScrollView,所以你可以滚动工作(也许你需要把你的ListView另一名家长中,以控制高度)

0

将ListView的layout_height更改为wrap_content

相关问题