Issue
How to scroll map automatically which is inside scrollview like Expedia Application?
Solution
Got the solution. First create custom scrollview. Put mapview inside scrollview. Then on onScrollChanged of custom scrollview, scroll the mapview like,
On CustomScrollView.java:
protected void onScrollChanged(int l, int t, int oldl, int oldt)
{
super.onScrollChanged(l, t, oldl, oldt);
scrollMap(l,t);
}
On 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);
}
Answered By - Mirant
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.