Download presentation
Presentation is loading. Please wait.
1
Mobile Computing Lecture#12 Graphics & Animation
2
Lecture Contents Graphics & Animations Drawing Shapes Programmatically Drawing Shapes through XML Frame Animation Bouncing Globe Example Tween Animation Example 2
3
Drawing a Shape 1. Import the graphics packages 2. Create a View 3. Create a ShapeDrawable to hold our Drawable 4. Create any Shape and assign it to mDrawable 5. The onDraw method is called to draw the graphics 6. Set the boundaries and draw the shape on the canvas 3
4
Drawing Rectangle 4
5
Drawing through XML <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"> <ImageView android:layout_width="fill_parent" android:layout_height="50dip" android:src="@drawable/rect1" /> 5
6
Drawing through XML 6 <shape xmlns:android="http://schemas.android.com/ apk/res/android" type="rectangle"> _______________________ public class Main extends Activity { @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.xmlrectangle); }
7
Multiple Shapes with XML 7
8
Multiple Shapes 8 SHAPE1 SHAPE5
9
Multiple Shapes 9 SHAPE2 LINE
10
Multiple Shapes 10
11
Frame Animation 11
12
Main Layout 12
13
Main.java 13
14
Main.java …. continue 14
15
Main.java …. continue 15
16
Main Points (Frame Animation Example) 1. Bind resources to the ImageView. 2. Call the subclasses MyAnimationRoutine and MyAnimatinoRoutine2 which start and stop the Animation respectively. 3. MyAnimationRoutine extends TimerTask to allow for a wait time before it starts the animation. 4. MyAnimationRoutine2 extends TimerTask to allow for a wait time before it stops the animation from running. 16
17
Bouncing Globe Example… 17
18
Bouncing Globe Example … 18
19
Bouncing Globe Example … 19
20
Tween Animation Example 20
21
Tween Animation Example 21
22
Tween Animation 22
23
News Feeds Example (News) 23
24
News Feeds Example (Layout) 24
25
NewsFeedActivity.java (code…) 25
26
NewsFeedActivity.java (code…) 26
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.