视图不显示 Android 中内容的最后 +- 50dp

View doesn't show the last +- 50dp of the content in Android

我一直在关注使用 Android Hive 中的选项卡制作 material 设计的教程。

现在我想在片段中添加一个 ScrollView。片段被添加到 ViewPager。但它不显示 ScrollView 中内容的最后 +-50 dp。我认为它在 layout_height 属性中的某个地方,但我不知道如何解决这个问题。

activity_main.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"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <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/ThemeOverlay.AppCompat.Light" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMode="fixed"
            app:tabGravity="fill"/>
    </android.support.design.widget.AppBarLayout>

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

Fragment_one.xml:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:id="@+id/scroll"
     android:layout_height="fill_parent"
     android:layout_width="fill_parent"
     tools:context="com.a42.pthong.philips.CompanyFragment">

     <LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_margin="@dimen/activity_horizontal_margin"
          android:orientation="vertical">

          <TextView
               android:text="@string/title"
               android:id="@+id/textView"
               android:textSize="20sp"
               android:textStyle="bold"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content" />
          <TextView
               android:id="@+id/content1"
               android:text="@string/content"
               android:textSize="12sp"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content" />

     </LinearLayout>

</ScrollView>

这是因为您正在使用 CoordinatorLayoutScrollView。将您的实现更改为 android.support.v4.widget.NestedScrollView 以实现正确的滚动。

CoordinatorLayout 滚动与 NestedScrollingChild 的子项一起正常工作。

回答了同类问题。