ScrollView不会一直滚动到底部

时间:2017-02-09 08:41:38

标签: android

我的ScrollView不会一直向下滚动,我在这里阅读了一些类似的问题,例如thisthis等。我尝试添加 10dp padding bottom ,但它没有帮助。下图显示了我的问题看起来如何

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是动态抓取和创建子项的视图。

1 个答案:

答案 0 :(得分:0)

正如Mehmet Kologlu所述,我将ScrollView固定为app:layout_heightPercent="80%"而不是wrap_content,这解决了我的问题。