android MapView always causes an OutOfMemoryError in nested elements

后端 未结 7 1414
我在风中等你
我在风中等你 2020-12-03 12:55

I am trying to create a MapView (currently without any overlays) inside some nested elements. It is basically something like ScrollView -> RelativeLayout -> Rela

相关标签:
7条回答
  • 2020-12-03 13:22

    Actually it is caused by Scrollview creating a buffer to contain the view at each possible position of the scrollbar to enable fast and smooth scrolling. Since a MapView is pretty large when the tiles are loaded during the measure phase then the resulting buffer created by ScrollView can be huge (around 128 M). Unless you set your emulator to have more than 256 M of ram and heap space, it will fail with an out of memory error. You could set your emulator to have 512M of ram and heap space but your app would crash on any device that has less than 512M of ram or insufficient heap space. The best thing to do is to remove the MapView from the ScrollView.

    0 讨论(0)
提交回复
热议问题