Animation drawing Concentric Circles
Here is an animation-related detailed introduction
Http://developer.android.com/intl/zh-cn/guide/topics/resources/animation-resource.html
There are a few things to note when implementing frame animations:
1) Frame animations cannot be automatically scaled down according to the size of your view settings
2) Each frame size needs to define the same size
Instance:
1. Implement picture frame in drawable (simple two frame is realized here)
The contents of the Frame0.xml are as follows:
<?xml version="1.0" encoding="Utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="Oval">
<solid android:color="@android: color/transparent" />
<size android:width="200DP" android:height="200DP"/>
</shape>
</item>
<item android:bottom="56DP"
android:left="56DP"
android:right="56DP"
android:top="56DP">
<shape android:shape="Oval">
<solid android:color="#FF16ae2b" />
</shape>
</item>
</layer-list>
The contents of the Frame1.xml are as follows:
<?xml version="1.0" encoding="Utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!--inner shadow of Outer circle--
<item>
<shape android:shape="Oval">
<solid android:color="@android: color/transparent" />
<size android:width="200DP" android:height="200DP"/>
</shape>
</item>
<item
android:bottom="36DP"
android:left="36DP"
android:right="36DP"
android:top="36DP">
<shape android:shape="Oval">
<stroke android:width="2DP " android:color= "#cF16ae2b" />
<solid android:color="@android: color/transparent" />
</shape>
</item>
<item
android:bottom="48DP"
android:left="48DP"
android:right="48DP"
android:top="48DP">
<shape android:shape="Oval">
<stroke android:width="2DP " android:color= "#FF16ae2b" />
<solid android:color="@android: color/transparent" />
</shape>
</item>
<item
android:bottom="56DP"
android:left="56DP"
android:right="56DP"
android:top="56DP">
<shape android:shape="Oval">
<solid android:color="#FF16ae2b" />
</shape>
</item>
</layer-list>
2. Implement animation in Res/anim
The contents of the Anim0.xml are as follows:
<?xml version="1.0" encoding="Utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/FRAME0" android:duration=" />"
<item android:drawable="@drawable/frame1" android:duration=" />"
</animation-list>
3. Code implementation
Private animationdrawable showdrawable = null;
protected void OnCreate (bundlesavedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
Showdrawable= (animationdrawable) context.getresources (). getdrawable (R.ANIM.ANIM0);
Showdrawable.setoneshot (TRUE);
This.setbackgrounddrawable (showdrawable); put it in a view
}
Drawing animations with animation