I have an Activity that mostly consists of a large MapView. On top of that MapView, I have a couple of other Views that I'm attempting to interact with programmatically.
My first problem occurred when I tried to use an AnimationListener to animate one of the Views on top of the MapView. The AnimationListener would not fire until I touched the MapView. This was fixed by ditching the AnimationListener and calling setVisibility()
and other code sequentially. It's not ideal, but it works fine.
My current problem occurs when trying to update a TextView that's on top of the MapView. I set the text, but it doesn't display until I physically touch the MapView. I've tried requesting focus and other things but to no avail.
Has anybody else experienced this and come up with a working solution?
You can call map.invalidate()
to refresh the MapView
you only need to wite the below code when your layout creates for mapview.
mapView = (MapView) findViewById(R.id.mapViewUsers);
mapView.onCreate(bundleSavedInstanceState);
mapView.onResume();//need to respond immediatly from mapview.
try {
MapsInitializer.initialize(context.getApplicationContext());
} catch (Exception e) {
e.printStackTrace();
}
mapView.getMapAsync(this);
来源:https://stackoverflow.com/questions/8697465/views-dont-update-until-mapview-is-touched