Android-android:persistentDrawingCache图片缓存

android:persistentDrawingCache (Google官方译文)

Defines the persistence of the drawing cache. The drawing cache might be enabled by a ViewGroup for all its children in specific situations (for instance during a scrolling.) This property lets you persist the cache in memory after
its initial usage. Persisting the cache consumes more memory but may prevent frequent garbage collection is the cache is created over and over again. By default the persistence is set to scrolling.

定义绘图的高速缓存的持久性。 绘图缓存可能由一个ViewGroup在特定情况下为其所有的子类启用,例如在一个滚动的过程中。
此属性可以在初次使用后保留在其在内存中的缓存。 坚持缓存会消耗更多的内存,但可能会阻止频繁的垃圾回收是反复创建缓存。 默认情况下持续存在设置为滚动。

Must be one or more (separated by '|') of the following constant values.

Xml文件中可以使用一下的值:

ConstantValueDescription
none
0x0The drawing cache is not persisted after use.
animation
0x1The drawing cache is persisted after a layout animation.
scrolling
0x2The drawing cache is persisted after a scroll.
all
0x3The drawing cache is always persisted.


XML中使用:

<android.support.v4.view.ViewPager  
        android:id="@+id/viewpager"  
        android:layout_width="fill_parent"  
        android:layout_height="fill_parent"  
        android:flipInterval="30"  
        android:persistentDrawingCache="animation"/> 


也可以在代码中设置
mContainer.setPersistentDrawingCache(ViewGroup.PERSISTENT_ANIMATION_CACHE);
        /**
         * persistentDrawingCache设置了控件的绘制缓存策略,一共有4中策略:
PERSISTENT_NO_CACHE 说明不在内存中保存绘图缓存; 
PERSISTENT_ANIMATION_CACHE 说明只保存动画绘图缓存;可以用来缓存大视图,以保持他们的缓存在每个之间动画。
PERSISTENT_SCROLLING_CACHE 说明只保存滚动效果绘图缓存
PERSISTENT_ALL_CACHES 说明所有的绘图缓存都应该保存在内存中。
         */

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值