Drawing animations with animation

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.