正如标题所说,需要太长时间才能让包含谷歌地图片段的布局(大约4xx毫秒)充气并导致滞后。如何解决这个问题?
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);
}
...
}