1 / 26

Mobile Computing

Mobile Computing. Lecture#12 Graphics & Animation. Lecture Contents. Graphics & Animations Drawing Shapes Programmatically Drawing Shapes through XML Frame Animation Bouncing Globe Example Tween Animation Example. Drawing a Shape. Import the graphics packages Create a View

zinna
Download Presentation

Mobile Computing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mobile Computing Lecture#12 Graphics & Animation

  2. Lecture Contents • Graphics & Animations • DrawingShapesProgrammatically • DrawingShapesthrough XML • Frame Animation • Bouncing Globe Example • Tween Animation Example

  3. Drawing a Shape • Import the graphics packages • Create a View • Create a ShapeDrawable to hold our Drawable • Create any Shape and assign it to mDrawable • The onDraw method is called to draw the graphics • Set the boundaries and draw the shape on the canvas

  4. Drawing Rectangle

  5. Drawing through XML <?xml version="1.0" encoding="utf-8"?> <ScrollViewxmlns: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"> <ImageViewandroid:layout_width="fill_parent" android:layout_height="50dip" android:src="@drawable/rect1" /> </LinearLayout> </ScrollView>

  6. Drawing through XML <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" type="rectangle"> <solid android:color="#FF0000FF"/> </shape>_______________________ public class Main extends Activity { @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.xmlrectangle); } }

  7. Multiple Shapes with XML

  8. Multiple Shapes SHAPE1<shape xmlns:android=“XXX” type="oval" > <solid android:color="#FFFFCC55"/> <padding android:left="10sp" android:top="4sp" android:right="10sp" android:bottom="4sp" /> <stroke android:width="1dp" android:color="#FFFFFFFF"/> </shape> SHAPE5 <shape xmlns:android="http://schemas.android.com/apk/res/android" type="oval"> <gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF" android:angle="270"/> <padding android:left="7dp" android:top="7dp" android:right="7dp" android:bottom="7dp" /> <corners android:radius="8dp" /> </shape>

  9. Multiple Shapes SHAPE2<shape xmlns:android=“xxxxx"> <solid android:color="#FF0000FF"/> <stroke android:width="4dp" android:color="#FFFFFFFF" android:dashWidth="1dp" android:dashGap="2dp" /> <padding android:left="7dp" android:top="7dp" android:right="7dp" android:bottom="7dp" /> <corners android:radius="4dp" /> </shape> LINE <shape xmlns:android=“xxxx" type="line" > <solid android:color="#FF00FF00"/> <stroke android:width="1dp" android:color="#FFFFFFFF“ android:dashWidth="1dp" android:dashGap="2dp"/> <padding android:left="1dp" android:top="25dp" android:right="1dp" android:bottom="25dp"/> <size android:height="10dp"/> </shape>

  10. Multiple Shapes

  11. Frame Animation

  12. Main Layout

  13. Main.java

  14. Main.java …. continue

  15. Main.java …. continue

  16. Main Points (Frame Animation Example) • Bind resources to the ImageView. • Call the subclasses MyAnimationRoutine and MyAnimatinoRoutine2 which start and stop the Animation respectively. • MyAnimationRoutineextends TimerTask to allow for a wait time before it starts the animation. • MyAnimationRoutine2 extends TimerTask to allow for a wait time before it stops the animation from running.

  17. Bouncing Globe Example…

  18. Bouncing Globe Example …

  19. Bouncing Globe Example …

  20. Tween Animation Example

  21. Tween Animation Example

  22. Tween Animation

  23. News Feeds Example (News)

  24. News Feeds Example (Layout)

  25. NewsFeedActivity.java (code…)

  26. NewsFeedActivity.java (code…)

More Related