NestedScrollView和CoordinatorLayout。发行:滚动 [英] NestedScrollView and CoordinatorLayout. Issue on Scrolling

本文介绍了NestedScrollView和CoordinatorLayout。发行:滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题,与 CoordinatorLayout NestedScrollView )(与设计支持库22.2.0 )

使用含量比 NestedScrollView 小我应该有一个固定的内容。 然而试图向上和向下滚动的内容,我可以得到该内容在自己的地方流离失所,再也没有。

下面一个小例子:

下面的code:

 < android.support.design.widget.CoordinatorLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:程序=htt​​p://schemas.android.com/apk/res-auto
    机器人:ID =@ + ID / main_content
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent>

    < android.support.design.widget.AppBarLayout
        机器人:ID =@ + ID / appbar
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        机器人:主题=@风格/ ThemeOverlay.AppCompat.Dark.ActionBar>

            < android.support.v7.widget.Toolbar
                机器人:ID =@ + ID /工具栏
                机器人:layout_width =match_parent
                机器人:layout_height =?ATTR / actionBarSize
                机器人:ATTR / colorPrimary后台=
                应用程序:popupTheme =@风格/ ThemeOverlay.AppCompat.Light
                应用程序:layout_scrollFlags =滚动| enterAlways/>

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

    < android.support.v4.widget.NestedScrollView
        机器人:layout_width =match_parent
        机器人:layout_height =match_parent
        应用程序:layout_behavior =@字符串/ appbar_scrolling_view_behavior>

        <的FrameLayout
            机器人:paddingTop =24dp
            机器人:ID =@ + ID / fragment_container
            机器人:layout_width =match_parent
            机器人:layout_height =match_parent
            机器人:填充=@扪/填充>

        < /的FrameLayout>

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

    < android.support.design.widget.FloatingActionButton
        机器人:ID =@ + ID / fab_action
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_gravity =结束|底
        机器人:layout_margin =16DP
        机器人:能见度=水涨船高
        机器人:SRC =@可绘制/ ic_done/>

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

解决方案

这也可以在 cheesesquare 演示拆卸时观察所有,但一卡在细节片段。

我能解决这个(现在)使用这个类:<一href="https://gist.github.com/EmmanuelVinas/c598292f43713c75d18e">https://gist.github.com/EmmanuelVinas/c598292f43713c75d18e

 &LT; android.support.v4.widget.NestedScrollView
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    应用程序:layout_behavior =com.evs.demo.layout.FixedScrollingViewBehavior&GT;
    .....
&LT; /android.support.v4.widget.NestedScrollView>
 

I have a strange issue with the CoordinatorLayout and the NestedScrollView )(with the design support library 22.2.0)

Using a content smaller than NestedScrollView I should have a fixed content. However trying to scroll up and down the content I can obtain that the content is displaced and never again in their own place.

Here a little sample:

Here the code:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        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:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:layout_scrollFlags="scroll|enterAlways" />

    </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">

        <FrameLayout
            android:paddingTop="24dp"
            android:id="@+id/fragment_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="@dimen/padding">

        </FrameLayout>

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

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab_action"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:layout_margin="16dp"
        android:visibility="gone"
        android:src="@drawable/ic_done" />

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

解决方案

This can also be observed in the cheesesquare demo when removing all but one card in the details fragment.

I was able to solve this (for now) using this class: https://gist.github.com/EmmanuelVinas/c598292f43713c75d18e

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="com.evs.demo.layout.FixedScrollingViewBehavior">
    .....   
</android.support.v4.widget.NestedScrollView>

这篇关于NestedScrollView和CoordinatorLayout。发行:滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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