NestedScrollView + AppBarLayout内容落后 [英] NestedScrollView + AppBarLayout content goes behind

查看:176
本文介绍了NestedScrollView + AppBarLayout内容落后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了类似于
的设计 https://github.com/chrisbanes/cheesesquare

一个可折叠的工具栏,当滚动时,崩溃中的图像

A collapsible toolbar with an image inside that collapse when scrolling down

<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:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/app_bar_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            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:contentScrim="?attr/colorPrimary"
                app:expandedTitleMarginEnd="64dp"
                app:expandedTitleMarginStart="48dp"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/pager"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/picture_heigth"
                    android:fitsSystemWindows="true"
                    app:layout_collapseMode="parallax">

                </android.support.v4.view.ViewPager>


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


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

        <android.support.v4.widget.NestedScrollView
            android:id="@+id/scroll_view"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"         
            android:foreground="?android:windowContentOverlay"

            app:layout_behavior="@string/appbar_scrolling_view_behavior">
            LinearLayout
            android:id="@+id/root"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

它的作品很棒,但并不总是...例如在线性布局里面我有一个看法在我的休息请求完成后填满。这样做有助于推动观众,当我向下滚动时,所有内容都会再次进入正确的位置。

It works greats, but not always... For example inside in linear layout I have a view that gets filled after my rest request complete. This has the effect to push the content BEHIND the Viewpager , when i scroll down and up again everything goes into the right place again.

我在一些SO线程上看到在NestedSCrollVew上设置fill_vertical,它正在修复一些问题。实际上,内容不会落后,但是scrollView的底部是CUT ...
通过放置一些底部边缘来修复问题,但是它是动态的我不知道提前有什么余量...

I saw on some SO thread that by setting "fill_vertical" on the NestedSCrollVew it was fixing some of the problem. It actually does, the content doesn't go behind BUT the bottom of the scrollView is CUT... By putting some bottom margin it fixes the problem but has it is dynamic i don't known advance what margin to put...

推荐答案

添加到您的LinearLayout焦点属性:

Add to your LinearLayout focus attributes:

        android:focusable="true"
        android:focusableInTouchMode="true"

这篇关于NestedScrollView + AppBarLayout内容落后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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