如何在Collapsingtoolbarlayout中正确使用地图片段 [英] How to use map fragment correctly in Collapsingtoolbarlayout

查看:121
本文介绍了如何在Collapsingtoolbarlayout中正确使用地图片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在CoordinatorLayout中向上/向下滑动地图视图时,此地图也会展开/折叠。

我希望地图可以上/下或其他移动事件以查看其他地方。只是在mapview中。



如何做到这一点。

When I slide a mapview up/down in CoordinatorLayout,this map will also be expanded/collapsed.
I want the map can be up/down or the other move events to see other places. just in mapview.

How to do this. Thanks in advance.

    <android.support.v4.widget.DrawerLayout  xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/drawerLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.CoordinatorLayout
            android:id="@+id/rootLayout"
            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="216dp"
                >

                <android.support.design.widget.CollapsingToolbarLayout
                    android:id="@+id/collapsingToolbarLayout"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    app:contentScrim="?attr/colorPrimary"
                    app:expandedTitleMarginStart="40dp"
                    app:layout_scrollFlags="scroll|exitUntilCollapsed"><!---->

                    <fragment
                        android:id="@+id/map"
                        android:name="com.google.android.gms.maps.MapFragment"
                        android:layout_width="match_parent"
                        android:layout_height="222dp"
                        app:layout_collapseMode="pin"/>


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

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


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

            <android.support.design.widget.TabLayout
                android:id="@+id/info_tabLayout"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_gravity="bottom"
                android:background="@android:color/white"
                app:layout_anchor="@+id/appbar"
                app:layout_anchorGravity="bottom"
                app:tabIndicatorColor="@android:color/background_dark" />

            <android.support.v4.view.ViewPager
                android:id="@+id/info_viewpager"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="40dp"
                app:layout_behavior="@string/appbar_scrolling_view_behavior" />



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



        <include layout="@layout/navigation" />

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


推荐答案

我解决了这个问题。看看这个 AppBarLayout。 Behavior.DragCallback
将它用于AppBarlayout,然后MapFragment将正常工作。

I solved this problem . look this AppBarLayout.Behavior.DragCallback Use it to AppBarlayout and then MapFragment will work fine.

更详细的实现点击这里..

这篇关于如何在Collapsingtoolbarlayout中正确使用地图片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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