相关疑难解决方法(0)

CollapsingToolbar无法使用不那么高的内容

我很确定这是一个bug,所以我要求解决方法.我的布局如下:

<CoordinatorLayout>

    <AppBarLayout>
        <CollapsingToolbarLayout>
            <ImageView/>
            <Toolbar/>
        </CollapsingToolbarLayout>
    </AppBarLayout>

    <android.support.v4.widget.NestedScrollView/> <!-- content here -->

</CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

我正在从网上检索内容,我不知道它有多高 - 可能是几行,可能很长.但是,我发现CollapsingToolbar当内容不足以覆盖整个屏幕时效果不佳.案例:

  • content.height > screen.height:工作; 滑动顶部/底部展开和折叠工具栏,以及滚动内容;

  • content.height < screen.height:没有.这是不是好,因为大部分的时间(content.height + expandedToolbar.height) > screen.height!

换句话说,当内容不够高时,即使内容+ expandedToolbar比整个屏幕高得多,它也不会对滚动手势做出反应并显示一些错误 - 可能需要十个手势来折叠工具栏一点点.因此,您很难到达内容的底部,因为工具栏已展开,所以内容隐藏在底部.

任何解决方法?

如果你想尝试,只需采取cheesesquare示例项目并删除(或减少)NestedScrollViewactivity_detail.xml中的内容[API17 here]

android android-support-library android-design-library androiddesignsupport

22
推荐指数
1
解决办法
6565
查看次数