2013-11-21 1 views
2

지도를 스크롤 뷰에 표시해야합니다.지도를 표시 할 수 있지만 화면을 스크롤하면지도가 희미 해집니다. 나는 스크린 샷을 첨부했다.지도 조각에서 페이딩 문제를 제거하는 방법

enter image description here

코드 :

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> 

답변

4
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