Android Map not scrolling properly in CollapsingToolbarLayout -
i have google map in collapsingtoolbarlayout. map displays perfectly, although map camera doesn't work well.
when try swipe map move other locations, animation not smooth, , doesn't register swiping map because coordinatorlayout overrides map.
this means map doesn't scroll when try to, example, swipe on map. coordinatorlayout scrolls instead (nestedscrollview moves instead of map changing location).
does know how around problem?
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/background_light" android:fitssystemwindows="true" android:id="@+id/coordlayout" > <android.support.design.widget.appbarlayout android:id="@+id/main.appbar" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginbottom="80dp" 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" app:layout_scrollflags="scroll|exituntilcollapsed" android:fitssystemwindows="true" app:contentscrim="?attr/colorprimary" app:titleenabled="true" app:expandedtitlemarginstart="48dp" app:expandedtitlemarginend="64dp" > <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:name="com.google.android.gms.maps.supportmapfragment" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_collapsemode="parallax" app:layout_scrollflags="scroll|enteralways" android:fitssystemwindows="true"/> </android.support.design.widget.collapsingtoolbarlayout> </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" android:padding="20dp" android:background="@color/colorprimary"> <linearlayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/linearlayout"> </linearlayout> </android.support.v4.widget.nestedscrollview> <android.support.design.widget.floatingactionbutton android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_margin="@dimen/activity_horizontal_margin" android:src="@drawable/dots" app:backgroundtint="#4fcd1e" app:layout_anchor="@id/main.appbar" app:layout_anchorgravity="bottom|right|end" android:id="@+id/fab" /> </android.support.design.widget.coordinatorlayout>
a bit late reply. add below mentioned code in activity oncreate() method.
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);
map scrolling become proper.
Comments
Post a Comment