1

我有以下绘制red_dot.xml:应用动画集塑造绘制

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" > 
    <solid android:color="#f00" /> 
    <size 
     android:width="30dp" 
     android:height="30dp"/> 
</shape> 

和动画pulse.xml:

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"> 
    <alpha 
     android:fromAlpha="1.0" 
     android:toAlpha="0.0" 
     android:duration="1000" 
     android:repeatMode="reverse" 
     android:repeatCount="infinite" /> 
</set> 

如何申请动画的绘制在一个XML文件,例如red_dot_animated?如果red_dot.xml是一个矢量文件,下面将有可能(但它不是,因为我们有一个形状)

<animated-vector xmlns:android="http://schemas.android.com/apk/res/android" 
    android:drawable="@drawable/red_dot_vector" > 
    <target 
     android:name="circle" 
     android:animation="@anim/pulse" /> 
</animated-vector> 

回答

0

你可以做的是创建一个简单的View并设置red_dot为背景,并应用animationview

<View 
    android:layout_width="30dp" 
    android:layout_height="30dp" 
    android:background="@drawable/red_dot" 
    android:id="@+id/anime_view" 
/> 

View animeView = findViewById(R.id.anime_view);//Apply animation to animeView 
+0

把它以可抽拉XML将不得不直接使用它的TextView的drawableLeft等方面的优势.. – PhilLab