Android-如何改善其中包含大量视图/图像的HorizontalScrollView [英] Android - how to improve HorizontalScrollView that has lots of views/images inside
问题描述
我有一个HorizontalScrollView,里面有很多视图和图像. 问题是,如果我里面有很多东西,我会收到"java.lang.OutOfMemoryError:位图大小超出VM预算"
I have a HorizontalScrollView that has lots of views and images inside it. The issue is that if I have lots of stuff inside it I will get a 'java.lang.OutOfMemoryError: bitmap size exceeds VM budget'
有什么方法可以使用某种缓存,或者在我向左/向右移动时添加/删除东西,以便它不会一直存储在内存中?
is there any way to use some kind of cache, or add/remove stuff as I move left/right so its not on memory all the time?
谢谢
推荐答案
I think what you want is the existing Gallery widget provided by Android.
Gallery是一个布局小部件,用于在水平滚动列表中显示项目并将当前选择项放置在视图的中心.
Gallery is a layout widget used to display items in a horizontally scrolling list and positions the current selection at the center of the view.
这篇关于Android-如何改善其中包含大量视图/图像的HorizontalScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!