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

醉酒当歌 提交于 2019-12-13 07:35:55

问题


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~


回答1:


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.



来源:https://stackoverflow.com/questions/16386881/whole-screen-turns-into-black-for-a-short-while-when-first-switching-between-fra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!