如何定义安卓动画

    xiaoxiao2026-08-17  11

    要准备至少两张图片,图片在切换的过程可以形成动画效果即可;

    定义动画文件,anim/loading.xml <?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false" >     <item android:drawable="@drawable/progress_loading_image_01" android:duration="150"/>     <item android:drawable="@drawable/progress_loading_image_02" android:duration="150"/> </animation-list> 在布局imageview中调用这个动画作为背景 <ImageView     android:id="@+id/loadingIv"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:background="@anim/loading"/> //得到动画对象,并开启 //开启动画         loading_layout = (LinearLayout) view.findViewById(R.id.loading_layout);         anim = (ImageView) view.findViewById(R.id.anim);         AnimationDrawable animationDrawable= (AnimationDrawable) anim.getDrawable();         animationDrawable.start();
    转载请注明原文地址: https://ju.6miu.com/read-1311287.html
    最新回复(0)