Yes
Yes

Reputation: 107

Whole screen turns into black for a short while when first switching between Fragment and MapFragment

I want to switch 2 fragments in the activity with FragmentTransaction and one is MapFragment.

In the first switch, the whole screen turn into black for a very short moment.

But in the last switch, the phenomenon gone.

Here is the demo vedio. http://www.youtube.com/watch?v=FDf-LTZT9Wk

And Here are some source code that I do the switching.

xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/my_container"
android:layout_width="match_parent"
android:layout_height="match_parent" ></RelativeLayout>

activity:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getSupportFragmentManager().beginTransaction().replace(R.id.my_container, new Fragment())
            .commit();
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_change:
        if (flag) {
            flag = false;
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.my_container, new Fragment()).commit();
        } else {
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.my_container, SupportMapFragment.newInstance()).commit();
            flag = true;
        }
        break;
    }
    return super.onOptionsItemSelected(item);
}

I can't realize why this happen...

If you know the reason of this phenomenon, or know how to solve it, please teach me!

Thanks~

Upvotes: 0

Views: 1129

Answers (1)

MaciejG&#243;rski
MaciejG&#243;rski

Reputation: 22232

This is a known issue.

http://code.google.com/p/gmaps-api-issues/issues/detail?id=4639

Maybe you can find some workaround on gmaps-api-issues for your case.

Upvotes: 1

Related Questions