帧动画

    xiaoxiao2021-03-25  85

    以前真没有见过,这次算是涨姿势了,原来帧动画是长这样子、 放到了drawable里面,直接拿来用的

    <?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/app_loading0" android:duration="150" /> <item android:drawable="@drawable/app_loading1" android:duration="150" /> <item android:drawable="@drawable/app_loading2" android:duration="150" /> <item android:drawable="@drawable/app_loading3" android:duration="150" /> </animation-list> <!--加载中..--> <LinearLayout android:id="@+id/ll_progress_bar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="80dp" android:gravity="center_vertical"> <ImageView android:id="@+id/img_progress" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/anim_list" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:text="努力加载中..." android:textColor="@color/colorTabText" android:textSize="14sp" /> </LinearLayout> protected LinearLayout ll_progress_bar; protected ImageView img_progress; // 动画 private AnimationDrawable mAnimationDrawable; private void findId() { ll_error_refresh = (LinearLayout) view.findViewById(R.id.ll_error_refresh); img_err = (ImageView) view.findViewById(R.id.img_err); ll_progress_bar = (LinearLayout) view.findViewById(R.id.ll_progress_bar); img_progress = (ImageView) view.findViewById(R.id.img_progress); }

    使用方法:

    mAnimationDrawable = (AnimationDrawable) img_progress.getDrawable(); mAnimationDrawable.start(); mAnimationDrawable.stop(); ll_progress_bar.setVisibility(View.GONE);
    转载请注明原文地址: https://ju.6miu.com/read-38592.html

    最新回复(0)