安卓开发中内存性能优化

1.布局中有帧动画导致内存溢出。加载动画的时候是会先把图片全部加载到内存中

 a.布局中src先不要写动画文件,使用的时候才加载

b.所以首先一点要压缩图片的空间  

c.可以减少图片张数

<ImageView
    android:id="@+id/video_guide_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    tools:src="@drawable/mkz_comic_video_guide_animation"/>

private void startVideoGuideAnimation() {
    guideVideoView.setVisibility(View.VISIBLE);
    guideVideoImageView.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.mkz_comic_video_guide_animation));//使用的时候才加载指明
    if (guideVideoImageView != null && guideVideoImageView.getDrawable() instanceof AnimationDrawable) {
        ((AnimationDrawable) guideVideoImageView.getDrawable()).start();
    }
    ReadSettingStore.setHasShowVideoGuide(this);
}

//未完待续,持续更新中

2.频繁GC 为什么会导致卡顿

GC的时候主线程是会停顿去做GC的,频繁GC就会导致主线程卡顿,要尽量避免频繁GC

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值