3

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>
WhiteBanana
  • 349
  • 4
  • 20
  • Check this repo [here](https://github.com/chrisbanes/cheesesquare/blob/master/app/src/main/res/layout/activity_detail.xml), I think you can try to use `mapView` to instead the `ImageView` in there. – bjiang Oct 30 '15 at 22:51

2 Answers2

4

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

For more detailed implementation click here..

Community
  • 1
  • 1
WhiteBanana
  • 349
  • 4
  • 20
0
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) appbar.getLayoutParams();
    AppBarLayout.Behavior behavior = new AppBarLayout.Behavior();
    behavior.setDragCallback(new AppBarLayout.Behavior.DragCallback() {
        @Override
        public boolean canDrag(AppBarLayout appBarLayout) {
            return false;
        }
    });
    params.setBehavior(behavior);
  • 1
    Code-only answers are generally frowned upon on this site. Could you please edit your answer to include some comments or explanation of your code? Explanations should answer questions like: What does it do? How does it do it? Where does it go? How does it solve OP's problem? See: [How to anwser](https://stackoverflow.com/help/how-to-answer). Thanks! – Eduardo Baitello Nov 07 '19 at 19:19
  • Android developer easily understood this code when look at a time . – Hemant Bharti Nov 08 '19 at 11:04