Black screen switching solution between Baidu map Fragment and fragment black screen

Source: Internet
Author: User

Black screen switching solution between Baidu map Fragment and fragment black screen

Many people who have used Baidu map are sad, and various bugs are unable to speak out. The most speechless phenomenon is the black screen phenomenon. For example, an Activity contains three Fragment, one of the Fragment nested MapView is used. When switching the three Fragment, there will be a clear black screen. This problem has occurred for a long time, and the SDK version exists very early, the latest SDK version still has this problem. The solution is as follows:


1. Manually call the onResume/onPause method of Fragment of MapView to set whether the view is visible, as shown below:

@ Override protected void OnPause () {mMapView. setVisibility (View. INVISIBLE); mMapView. onPause (); super. onPause ();} @ Override protected void onResume () {mMapView. setVisibility (View. VISIBLE); mMapView. onResume (); super. onResume ();}

2. Use a View to replace the Fragment with a nested MapView in the XML layout of the Activity. To display the Fragment, set the View to visible, and set it to invisible when not in use.

  <FrameLayout        android:layout_width="match_parent"        android:layout_height="match_parent"        android:orientation="vertical" >        <FrameLayout            android:id="@+id/mapFrameLayout"            android:layout_width="match_parent"            android:layout_height="match_parent" >        </FrameLayout>        <FrameLayout            android:id="@+id/otherFrameLayout"            android:layout_width="match_parent"            android:layout_height="match_parent"            android:visibility="invisible" >        </FrameLayout>    </FrameLayout> 

3. Use the same nested Fragment object with MapView throughout the lifecycle of the Activity. You do not need to repeat the new instance. This is the most important thing.


Demo: http://download.csdn.net/detail/easyer2012/8968903







Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.