android google map v2 - inflate map fragment layout take too long and results in lagging

839 Views Asked by At

As title said, it takes too long to inflate the layout containing a google map fragment (around 4xx ms) and results in a lagging. How to solve this problem?

fragment_google.map.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<fragment
    android:id="@+id/google_map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.SupportMapFragment"
    />
</FrameLayout>

MapFragment

public class MyMapFragment extends Fragment {
    ...
    //this method consumes 4xx ms to done
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_google_map, container, false);
    }
   ...
}
0

There are 0 best solutions below