CollapsingToolbarLayout不与NestedScrollView很好地工作 [英] CollapsingToolbarLayout doesn't work well with NestedScrollView

查看:156
本文介绍了CollapsingToolbarLayout不与NestedScrollView很好地工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个活动,其中图像应该崩溃与工具栏和下方只有文字是可见的。但是当工具栏被倒塌,有显示工具栏和NestedScrollView之间有很大的差距

I made an activity where image should collapse with toolbar and only text below would be visible. But When Toolbar being collapsed, there shows up a large gap between Toolbar and NestedScrollView

<android.support.design.widget.CoordinatorLayout xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/coordinatorLayout"
    android:layout_width="match_parent"
    android:background="@color/white"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        app:elevation="5dp"
        app:layout_collapseMode="pin"
        android:fitsSystemWindows="true"
        android:layout_height="wrap_content">

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:toolbarId="@+id/toolbar"
            android:id="@+id/collapsing"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <com.noframe.farmisagronom.util.ResizibleImageView
                android:id="@+id/image_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_scrollFlags="scroll|enterAlwaysCollapsed"
                android:minHeight="100dp"
                android:maxHeight="400dp"
                android:fitsSystemWindows="true"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.5"
                android:scaleType="centerCrop"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                android:minHeight="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                />

        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>
    <android.support.v4.widget.NestedScrollView
        android:id="@+id/nesteview"
        app:layout_anchorGravity="top"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
         .....
    </android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>

和这个活动看起来非常好。

And this activity looks really good.

但是,当我向上滚动NestedScrollView这正好失控。

But when i scroll up the NestedScrollView this goes out of control.

该工具栏和文本之间几乎没有空间让我心烦。

This little space between toolbar and text is getting on my nerves.

请注意,如果在NestedScrollView问题大文本将不会显示出来,但如果NestedScrollView +倒塌工具栏不会采取一切手机屏幕上,那么它们之间的差距。

推荐答案

添加:

android:layout_gravity="fill_vertical"

到NestedScrollView为我工作。

to the NestedScrollView worked for me.

这篇关于CollapsingToolbarLayout不与NestedScrollView很好地工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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