2

次の描画可能な 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>

red_dot_animated などの XML ファイルのドローアブルにアニメーションを適用するにはどうすればよいですか? 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>
4

1 に答える 1