动画 帧动画
<TextView android:id="@+id/fa_search_room_history_tv_live_status" android:layout_width="wrap_content" android:layout_height="16dp" android:background="@drawable/fa_pub_list_label_second" android:gravity="center" android:lines="1" android:paddingLeft="6dp" android:paddingRight="6dp" android:textColor="@color/fa_white" android:textSize="@dimen/fa_text_size_10" android:drawablePadding="@dimen/fa_common_3dp" android:drawableLeft="@drawable/fa_live_play_anim" android:visibility="gone" tools:visibility="visible" />
<?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/live_play_anim1" android:duration="100"/> <item android:drawable="@drawable/live_play_anim2" android:duration="100"/> <item android:drawable="@drawable/live_play_anim3" android:duration="100"/> <item android:drawable="@drawable/live_play_anim4" android:duration="100"/> <item android:drawable="@drawable/live_play_anim5" android:duration="100"/> <item android:drawable="@drawable/live_play_anim6" android:duration="100"/> <item android:drawable="@drawable/live_play_anim7" android:duration="100"/> </animation-list>
private void startAnimation(TextView liveStatusTv){ Drawable backgroundSec = liveStatusTv.getBackground(); backgroundSec.setColorFilter(Color.parseColor("#FF4466"), PorterDuff.Mode.MULTIPLY); Drawable[] drawables = liveStatusTv.getCompoundDrawables(); if(drawables[0] != null && drawables[0] instanceof AnimationDrawable){ AnimationDrawable liveStatusAnimation = (AnimationDrawable)drawables[0]; liveStatusAnimation.start(); } }