2013-04-06 284 views

回答

0

得到了解決方案。 首先創建自定義滾動視圖。 將scrollview放入滾動視圖中。 然後在自定義滾動型onScrollChanged,滾動的MapView一樣,

在CustomScrollView.java:

protected void onScrollChanged(int l, int t, int oldl, int oldt) 
{ 
    super.onScrollChanged(l, t, oldl, oldt); 
    scrollMap(l,t); 
} 

在YourActivity.java:

public void scrollMap(int x, int y) 
{ 
    int scrollLength = scrollView.getMeasuredHeight(); 
    int mapViewHeight = mapView.getMeasuredHeight(); 

    int mapViewCenter = (int)(mapViewHeight/2); 
    int scrollMapHeight = (mapViewCenter + ((int)((mapViewHeight*y)/scrollLength))); 

    scrollMapHeight = (int)((mapViewCenter - scrollMapHeight)/(1.5)); 

    if(scrollMapHeight<0)   
    mapView.scrollTo(x, scrollMapHeight);  
}