3

我有一个片段内一个简单的折叠式工具,这是一个viewpager内侧tablayout:CollapsingToolbarLayout exitUntilCollapsed导致布局问题与NestedScrollView

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


    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="192dp" 
     android:fitsSystemWindows="true" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 
     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      app:expandedTitleMarginBottom="80dp" 
      app:expandedTitleMarginEnd="64dp" 
      app:expandedTitleMarginStart="48dp" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed" 
      android:background="@color/red"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/anim_toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:layout_collapseMode="pin" 
       app:layout_scrollFlags="scroll|enterAlways" 
       app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 
     </android.support.design.widget.CollapsingToolbarLayout> 
    </android.support.design.widget.AppBarLayout> 


    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 


     </LinearLayout> 
    </android.support.v4.widget.NestedScrollView> 

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

当我的片段首次加载这一切工作正常,但是当片段reshown交换标签后,我不能再滚动到NestedScrollView的最底部。我的内容的缺失部分与工具栏高度相同(更改工具栏高度会更改缺少的部分高度)。

这里的未涡卷视图:

enter image description here

当滚动至底部有未示出的部分,在该例子还有另一个“文本6”的TextView这就是关断屏幕,并且不能被访问。

enter image description here

在某些选项卡(我有6)我永远不能访问缺少的部分,对他人它遵循的模式:

  1. 可以滚动到下
  2. 更改选项卡,然后再返回因此该片段被杀死
  3. 不能滚动到底
  4. 更改多个标签
  5. 片段被重新充气选择选项卡时再次
  6. 能滚动到底

任何帮助,将不胜感激。

+0

您是否试过将所有的适合系统Windows删除? – natario

+0

另请参阅:在CTL上使用app:layout_scrollFlags =“scroll | enterAlways | enterAlwaysCollapsed | exitUntilCollapsed”,并删除工具栏上的滚动标志。 – natario

+0

我玩过fitsSystemWindows是的,它需要设置为false,因为包含视图中的TabBarLayout的问题http://stackoverflow.com/questions/33100985/why-does-tablayout-leave-a-gap- for-the-navbar-when-in-immersive-mode – Leon

回答

0

尝试这些更改。看看差异。

<android.support.design.widget.AppBarLayout 
    android:layout_height="192dp" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.CollapsingToolbarLayout 

     android:layout_height="wrap_content" 
     android:fitsSystemWindows="true"> 

     <android.support.v7.widget.Toolbar 
      android:layout_height="?attr/actionBarSize"/> 

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


<android.support.v4.widget.NestedScrollView 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    android:fitsSystemWindows="true"> 

    <LinearLayout 
     android:layout_height="match_parent"> 
    </LinearLayout> 

</android.support.v4.widget.NestedScrollView> 
+0

不要相信它会让事情变得更糟。向NestedScrollView添加fitsSystemWindows =“true”不起作用,但CollapsingToolbarLayout上的wrap_content增加了截断区域的大小并打破了我的折叠工具栏。工具栏更改颜色,标题从折叠工具栏中消失。谢谢你尝试。 – Leon