【问题标题】:How to remove fading issue in Map Fragment如何消除地图片段中的褪色问题
【发布时间】:2013-11-21 07:58:46
【问题描述】:

我必须在滚动视图中显示地图我可以显示地图,但是当我滚动屏幕时,地图正在消失。我附上了屏幕截图。

代码:

FragmentManager myFragmentManager = getSupportFragmentManager();
    SupportMapFragment mySupportMapFragment = (SupportMapFragment) myFragmentManager.findFragmentById(R.id.map);
        _myMap = mySupportMapFragment.getMap();

XML:

<RelativeLayout
       android:id="@+id/map_contact_layout"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:layout_marginLeft="5dip"
       android:layout_toLeftOf="@+id/grid_layout"
       android:layout_weight="1" >

       <fragment
           android:id="@+id/map"
           android:name="com.google.android.gms.maps.SupportMapFragment"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content" />
 </RelativeLayout>

【问题讨论】:

    标签: android map scrollview fade


    【解决方案1】:
    I was able to work around the issue with a hack. I extended ScrollView so I could get notified on scroll events. I used the ObservableScrollView implementation from Synchronise ScrollView scroll positions - android.
    
    I added to my onCreate():
    
    ObservableScrollView sv = (ObservableScrollView) findViewById(R.id.scroll);
    sv.setScrollViewListener(this);
    
    Then, when I receive a scroll changed event, I toggle the visibility of the whole view, which forces a re-layout, which prevents the black box from appearing.
    
    public void onScrollChanged(ObservableScrollView sv, int x, int y, int oldx, int oldy) {
        sv.setVisibility(View.GONE);
        sv.setVisibility(View.VISIBLE);
    }
    
    I tried to invalidate() the map view, and toggling the visibility of just the map view, but neither worked. Thankfully toggling the visibility of the whole view doesn't cause any flicker or other strange behavior.
    
    There probably is a better solution, but at this point, this is the only thing I've found that seems to work
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多