2017-02-09 64 views
1

我的ScrollView不会一直滚动到底部,我已经阅读了几个类似的问题,如thisthis等。我尝试添加10dp填充底部但它没有帮助。下面的图片是我的问题是如何看起来ScrollView不会滚动到底部

notScrolled

和下面的图片是它应该如何看(增加150dp填充底部

scrolled

正如你可以看到有是底部的另一项目。我也不能简单地保持150填充底因为显示在列表中的项目数量正在从数据库中取出,并可能会有所不同,因此,我需要增加/减少填充

这里是我的XML的片段

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

<android.support.percent.PercentRelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/weekDisplayed"> 

    <android.support.percent.PercentRelativeLayout 
     app:layout_heightPercent="10%" 
     android:layout_width="match_parent" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:id="@+id/header" 
     android:background="@drawable/main_calendar_header_menu"> 

      <ImageView 
       android:layout_width="35dp" 
       android:layout_height="35dp" 
       app:layout_marginLeftPercent="3%" 
       android:layout_centerVertical="true" 
       android:id="@+id/prevIcon" 
       android:layout_alignParentStart="true" 
       android:layout_alignParentLeft="true" 
       android:background="@mipmap/arrow_left"/> 

     <TextView 
      android:text="Placeholder" 
      android:layout_centerHorizontal="true" 
      android:id="@+id/periodTextView" 
      android:layout_centerInParent="true" 
      android:textSize="17sp" 
      android:textStyle="bold" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content"/> 

     <ImageView 
      android:layout_width="35dp" 
      android:layout_height="35dp" 
      app:layout_marginRightPercent="3%" 
      android:layout_centerVertical="true" 
      android:id="@+id/nextIcon" 
      android:layout_alignParentEnd="true" 
      android:layout_alignParentRight="true" 
      android:background="@mipmap/arrow_right"/> 

    </android.support.percent.PercentRelativeLayout> 

     <ScrollView 
      android:id="@+id/scrollView" 
      android:layout_below="@+id/header" 
      android:layout_centerHorizontal="true" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

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

       <RelativeLayout 
        android:layout_height="wrap_content" 
        android:layout_width="match_parent" 
        android:id="@+id/daysContainer" 
        android:paddingLeft="10dp" 
        android:paddingRight="10dp" 
        android:paddingBottom="10dp"> 

       </RelativeLayout> 


       <View 
        android:layout_width="match_parent" 
        android:layout_height="10dp" 
        android:background="@drawable/shadow_middle" 
        android:layout_below="@+id/daysContainer" 
        android:id="@+id/shadowMiddle"/> 

       <RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/shadowMiddle" 
        android:id="@+id/summaryContainer" 
        android:paddingBottom="150dp"> 

        <RelativeLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:paddingLeft="10dp" 
         android:paddingRight="10dp" 
         android:id="@+id/commissionSummaryContainer" 
         android:layout_alignParentTop="true"> 

        </RelativeLayout> 

        <View 
         android:layout_height="10dp" 
         android:layout_width="match_parent" 
         android:id="@+id/shadowBottom" 
         android:layout_below="@+id/commissionSummaryContainer" 
         android:background="@drawable/shadow_middle"/> 

        <RelativeLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:paddingLeft="10dp" 
         android:paddingRight="10dp" 
         android:id="@+id/absenceSummaryContainer" 
         android:layout_below="@+id/shadowBottom"> 

        </RelativeLayout> 

       </RelativeLayout> 

      </RelativeLayout> 

    </ScrollView> 

</android.support.percent.PercentRelativeLayout> 

@+id/daysContainer@+id/commissionSummaryContainer@+id/absenceSummaryContainer在哪里它的孩子被取出,并动态创建的意见。

+0

您是否尝试在属性alignParentBottom = true的RelativeLayout(ScrollView的子项)内添加一个虚拟视图(如android.support.v4.widget.Space)? –

+1

尝试为您的滚动视图提供'app:layout_heightPercent =“90%”' –

+0

而不是使用PercentRelativeLayout使用Relative布局。 – nnn

回答

0

由于Mehmet Kologlu说,我给了我的ScrollView固定高度app:layout_heightPercent="80%"而不是wrap_content并解决了我的问题。

相关问题