Google Maps Android API V2 blacking out part of layout

前端 未结 8 1415
-上瘾入骨i
-上瘾入骨i 2021-02-04 13:48

I\'m trying to integrate Google Maps Android API v2 into my Android Application. I\'m placing the Google Map in the middle of my layout. It works great when the layout is able t

8条回答
  •  被撕碎了的回忆
    2021-02-04 14:31

    I was able to adapt the above for the same issue in a Viewpager by overriding onPageScrolled in the FragmentPagerAdapter:

    @Override
    public void onPageScrolled(int position, float positionOffset, 
                               int positionOffsetPixels) {
        if ((position == 0 && positionOffsetPixels > 0) ||
            (position == 1 && positionOffsetPixels == 0)) {
            MyFragment blackedOutFragment = (MyFragment) getSupportFragmentManager()
                    .findFragmentByTag("android:switcher:" + R.id.pager + ":1");
            if (blackedOutFragment != null) {
                blackedOutFragment.getView().setVisibility(View.GONE);
                blackedOutFragment.getView().setVisibility(View.VISIBLE);
            }
        }
    }
    

    Where position 0 in the Viewpager is a Fragment holding a MapFragment and position 1 is the Fragment getting blacked out after the scroll.

提交回复
热议问题