ScrollView不能完全滚动到底部 [英] ScrollView not scrolling bottom completely

查看:120
本文介绍了ScrollView不能完全滚动到底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在您将其标记为重复之前,让我告诉您,我已经搜索了所有答案,但都是徒劳的.

Before you mark it duplicate, let me tell you that I have searched for every answer but all in vain.

我正在将TabsActionbar一起使用.

我已将许多解决方案中建议的设置为ScrollViewandroid:layout_height="match_parent".

I have set android:layout_height="match_parent" of ScrollView as suggested in many solutions.

我还按照以下建议从所有布局中删除了android:layout_gravity="center": Android滚动视图在布局中隐藏顶部内容

I also have removed android:layout_gravity="center" from all layouts as suggested by: Android scrollview hiding top content in layout

我也设置了android:fillViewport="true"但没有运气.

I also have set android:fillViewport="true" but no luck.

我想念的其他任何骇客吗?

Any other hack that I am missing?

<?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="match_parent"
    android:fillViewport="true">
<LinearLayout
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <CalendarView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/calendarView" />

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

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:hint="Guest"/>

        <NumberPicker
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

        </NumberPicker>

    </LinearLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/title_time_slot"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/title_add_on"/>

    <Button
        android:id="@+id/btn_confirm"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/title_btn_confirm"/>
</LinearLayout>

</ScrollView>

这是活动的xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.squincy.wspace.ui.HomeActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="@dimen/appbar_padding_top"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/AppTheme.PopupOverlay">

        </android.support.v7.widget.Toolbar>

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabTextColor="@color/app_color_black"
            app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"
            app:tabIndicatorColor="@color/app_color_black"
            app:tabGravity="center"
            app:tabMode="scrollable"/>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <!--<android.support.design.widget.FloatingActionButton-->
        <!--android:id="@+id/fab"-->
        <!--android:layout_width="wrap_content"-->
        <!--android:layout_height="wrap_content"-->
        <!--android:layout_gravity="end|bottom"-->
        <!--android:layout_margin="@dimen/fab_margin"-->
        <!--android:src="@android:drawable/ic_dialog_email" />-->

</android.support.design.widget.CoordinatorLayout>

推荐答案

我认为您应该尝试NestedScrollView

<android.support.v4.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

只需用这个替换您的ScrollView

我正在我的应用程序中使用它,并且效果很好

I am using it in my app and it works perfectly

这篇关于ScrollView不能完全滚动到底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆