TestAnimationActivity.java 文件源码

java
阅读 31 收藏 0 点赞 0 评论 0

项目:AndroidUiKit 作者:
@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        View animView = findViewById(R.id.tv_view);
        animView.setBackgroundResource(R.drawable.test_frame_anim);
        ((AnimationDrawable) animView.getBackground()).start();
//经过运行查看内存比较。传统用法,一次性加载所有帧,内存消耗高,容易溢出导致奔溃。 FrameAnimDrawable 只加载当前动画帧,用完即释放,内存消耗少,动画质量媲美AnimationDrawable。
//        int[] RES_IDS = new int[]{
//          R.drawable.test_pic_01,
//          R.drawable.test_pic_02,
//          R.drawable.test_pic_03,
//          R.drawable.test_pic_04,
//          R.drawable.test_pic_05,
//          R.drawable.test_pic_06,
//          R.drawable.test_pic_07,
//          R.drawable.test_pic_08,
//          R.drawable.test_pic_09,
//          R.drawable.test_pic_10,
//        };

//        FrameAnimDrawable drawable = new FrameAnimDrawable(5, RES_IDS, getResources());
//        animView.setBackgroundDrawable(drawable);
//        drawable.start();
    }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号