Mobile Computing Systems


Animation x = AnimationUtils.loadAnimation


Download 10.9 Kb.
bet2/4
Sana18.06.2023
Hajmi10.9 Kb.
#1563379
1   2   3   4
Animation x = AnimationUtils.loadAnimation(
getApplicationContext(), R.anim.abovexmlfile );
someView.startAnimation(x);

3. Drawable Animation

  • We can load and display a series of Drawable resources (e.g. images) one after another.

3. Drawable Animation

  • Define animation-list in XML: res/drawable
  • Use AnimationDrawable inside your code

xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot=“false"> <item android:drawable="@drawable/pic1" android:duration=“1000" /> <item android:drawable="@drawable/pic2" android:duration=“1000" /> <item android:drawable="@drawable/pic1" android:duration=“1000" /> <item android:drawable="@drawable/pic2" android:duration=“1000" /> animation-list>
someImgView.setBackgroundResource(R.drawable.abovexml);
((AnimationDrawable)someImgView.getBackground()).start();

Code Practice:

  • Get a few images and copy: res/drawable/
  • Create an XML file: res/drawable/my_anim_list
  • Add an ImageView and set Background
  • Use AnimationDrawable to start animation

Graphics Overview

  • Canvas and Drawables
  • Hardware Acceleration (think GPU)
  • OpenGL (framework API and NDK)

Bitmap
drawRect()
drawRect()
drawCircle()

Canvas

2D Drawing

  • Drawable:
    • Put Drawables (into a View)
    • Less work, less control, less efficiency
  • Canvas:
    • Draw on the Canvas (of a View)
    • More work, more control, more efficiency

1. Using Drawables

  • Putting Drawables into a View

res/drawable/Queen.png
Four
ButtonViews
res/drawable/tfade.xml

Download 10.9 Kb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling