在CoordinatorLayout平移谷歌地图会导致recyclerview在Android设计支持库23.0.1滚动 [英] Panning google map in CoordinatorLayout causes recyclerview to scroll in android design support library 23.0.1

查看:465
本文介绍了在CoordinatorLayout平移谷歌地图会导致recyclerview在Android设计支持库23.0.1滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的地图是在其中嵌套在一个appBarLayout collapsingToolbarLayout。
在22.2.0版本和Android设计支持库22.2.1,我可以平移地图独立于coordinatorLayout的,但23.0.1身边,如果我尝试横跨在北/南轴线地图进行平移,它所造成的recyclerview滚动向上/向下。这是一个错误,还是有办法从appBarLayout触摸事件传递给mapFragment?

The map is in a collapsingToolbarLayout which is nested in an appBarLayout. In versions 22.2.0 and 22.2.1 of the android design support library, I could pan around the map independently of the coordinatorLayout but in 23.0.1, if i try to pan across the map in the north/south axis, it causes the recyclerview to scroll up/down. Is this a bug or is there a way to pass the touch events from the appBarLayout to the mapFragment?

<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.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways">

        <fragment
            android:id="@+id/mapFragment"
            android:name="com.google.android.gms.maps.MapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_collapseMode="parallax" />


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

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

<android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#44CCFF"
    app:behavior_overlapTop="184dp"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|right"
    android:layout_margin="16dp"
    android:src="@drawable/ic_list_white_24dp"
    app:backgroundTint="#3366FF"
    app:fabSize="normal" />

推荐答案

我面临同样的问题,解决了这种方式。

I faced the same problem and solved it this way.

CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams();
AppBarLayout.Behavior behavior = new AppBarLayout.Behavior();
behavior.setDragCallback(new AppBarLayout.Behavior.DragCallback() {
       @Override
       public boolean canDrag(AppBarLayout appBarLayout) {
            return false;
       }
});
params.setBehavior(behavior);

这篇关于在CoordinatorLayout平移谷歌地图会导致recyclerview在Android设计支持库23.0.1滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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