首页 > 解决方案 > 将谷歌地图放入 AppBarLayout

问题描述

我想将谷歌地图片段放入 AppBar 布局,但是当地图处于 Appbar 布局中时,无法进行拖动和缩放控制。有解决这个问题的办法吗?

<android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:fitsSystemWindows="true">

        <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:expandedTitleMarginStart="48dp"
            app:expandedTitleMarginEnd="64dp">

            <fragment
                android:id="@+id/map"
                class="com.stategram.app.ui.MapFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

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

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

标签: androidgoogle-mapsontouchlistenerandroid-coordinatorlayoutandroid-appbarlayout

解决方案


推荐阅读