Here is my layout. The main idea is a ViewPager with few fragments and action bar above. I sucessfully added a fragment with a SupportMapFragment inside of it. But I ran into a problem in android 4.0.4. When I use this layout below, my map frequently jumps over AppBarLayout. When jump occurs, I can see black rectangle on bot and it's size visually equal to AppBarLayout size. These jumps occur with every map update(zooming, moving and markers add/edit/remove).
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".activities.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/AppTheme.TabLayout" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
What I've tried:
If I remove
app:layout_behavior="@string/appbar_scrolling_view_behavior"
then my map fills all the view space(expected result) and no jumping occurs.
- If I change CoordinatorLayout with LinearLayout, jumping stops as well.
But I want to save features of CoordinatorLayout, so the 2nd way doesn't fit all my needs. The first one requires me to calculate top offset and or hardcode top margin, what I don't think is a good idea.
I suppose, that the problem is, when map updates it places in (0,0) and then with this
app:layout_behavior="@string/appbar_scrolling_view_behavior"
is moved to right position. But I am not quite sure. Maybe someone has already met this problem and can advise me how can I fix map jumping issue?