Views Don't Update Until MapView is Touched

荒凉一梦 提交于 2019-12-07 07:14:58

问题


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?


回答1:


You can call map.invalidate() to refresh the MapView




回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!