【问题标题】:ScrollView not scrolling bottom completelyScrollView 没有完全滚动底部
【发布时间】:2016-04-25 19:18:25
【问题描述】:

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

我正在使用 TabsActionbar

我已按照许多解决方案中的建议设置了 android:layout_height="match_parent"ScrollView

我还按照以下建议从所有布局中删除了android:layout_gravity="center"Android scrollview hiding top content in layout

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

我还缺少其他任何技巧吗?

<?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>

【问题讨论】:

  • 可以提供截图吗?
  • @petey 当然。检查更新
  • 尝试在 LinearLayout 上添加一个 layout_marginBottom,它是 ScrollView 的直接子级,看看它是否调整
  • @ljpv14 没用。
  • 您是否使用ActionBar 并将navigationMode 设置为NAVIGATION_MODE_TABS?如果是这样,请尝试将其更改为使用ToolbarTabLayout,因为ActionBar#setNavigationMode 已被弃用。

标签: android android-scrollview


【解决方案1】:

我觉得你应该试试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

我在我的应用程序中使用它,它运行良好

【讨论】:

    【解决方案2】:

    尝试将 paddingBottom 添加到 ScrollView 内的 LinearLayout。

    如果这不起作用,请尝试在 ScrollView 中添加 Space 作为 LinearLayout 的最后一个子项,如下所示:

    <ScrollView
        <LinearLayout
           // other views
    
            <Space
                android:layout_width="match_parent"
                android:layout_height="required_spacing_in_dp" />
    
        </LinearLayout>
    </ScrollView
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-13
      • 2013-02-14
      • 1970-01-01
      • 2011-02-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多