Skip to content

Instantly share code, notes, and snippets.

@happycodinggirl
Last active August 30, 2017 21:00
Show Gist options
  • Save happycodinggirl/4f8ddf5853c40aaa1c78 to your computer and use it in GitHub Desktop.
Save happycodinggirl/4f8ddf5853c40aaa1c78 to your computer and use it in GitHub Desktop.
textView和ImageView不同的animate方式
package com.sqisland.android.animated_vector_drawable;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import android.widget.TextView;
/**
* Created by happycodinggirl on 2015/4/6.
*/
public class AnimateUtils {
public void animateDrawables(TextView view) {
if (!(view instanceof TextView)) {
return;
}
TextView textView = (TextView) view;
for (final Drawable drawable : textView.getCompoundDrawables()) {
if (drawable instanceof Animatable) {
((Animatable) drawable).start();
}
}
}
private void animate(ImageView imageView) {
Drawable drawable = imageView.getDrawable();
if (drawable instanceof Animatable) {
((Animatable) drawable).start();
}
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/myview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="2dp"
android:drawableBottom="@drawable/myrect" />
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/face"
tools:context=".PathMorphActivity"/>
</LinearLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment