MapFragment原因ViewPager闪烁 [英] MapFragment causes flickering in ViewPager

查看:393
本文介绍了MapFragment原因ViewPager闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的(支持)MapFragment内的(支持)ViewPager,填补了一个FragmentPagerAdapter。

I use a (Support)MapFragment inside a (Support)ViewPager, filled by a FragmentPagerAdapter.

该ViewPager由三个片段,在右边的地图片段:| X | X |地图|。当我刷卡从第一个分片的权利,死整个UI明显重绘的MapFragment被加载,并且屏幕闪烁。一旦地图加载首次屏幕之间刷卡正常工作。

The ViewPager consists of three fragments, with the map fragment on the right: |x|x|map|. When I swipe to the right from the first fragment, die whole UI visibly redraws as the MapFragment is loaded and the screen flickers. Once the map is loaded for the first time swiping between screens works fine.

我该如何解决这个问题?

How can I fix this?

推荐答案

我与我的项目(​​相当复杂)结构有同样的问题: - > HostFragment与ViewPager - HostActivity>的ListView嵌入式MapFragment

I had the same issue with my project's (rather complex) structure: HostActivity -> HostFragment with ViewPager -> ListView with embedded MapFragment.

我试图解决这个问题,下面的这GMaps实现-API的问题线程,但没有运气(虽然我建议你阅读它,因为它提供了对这个问题本身的一些背景)。

I tried to solve this issue following this gmaps-api-issues thread but with no luck (though I recommend reading it as it provides some background on the issue itself).

然后,我偶然发现了这篇博客文章它的伎俩对我来说:

Then I stumbled upon this blog post and it did the trick for me:

public void onCreate(Bundle savedInstanceState) {
    ...
    ViewPager pager = (ViewPager)findViewById(R.id.pager);
    ...
    pager.setAdapter(adapter);
    pager.requestTransparentRegion(pager); // This line solved the problem for me
    ...
}

这篇关于MapFragment原因ViewPager闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆