Presentation is loading. Please wait.

Presentation is loading. Please wait.

Flag Quiz App 1 CS7030: Mobile App Development. assets Folder 2 CS7030: Mobile App Development  drawable folder – Image contents at the root level 

Similar presentations


Presentation on theme: "Flag Quiz App 1 CS7030: Mobile App Development. assets Folder 2 CS7030: Mobile App Development  drawable folder – Image contents at the root level "— Presentation transcript:

1 Flag Quiz App 1 CS7030: Mobile App Development

2 assets Folder 2 CS7030: Mobile App Development  drawable folder – Image contents at the root level  assets folder – Images can be organized in subfolders – Accessed via AssetManager  AssetManager open an InputStream to read image file name; next create a Drawable object from the stream; finally display the object on an ImageView using setImageDrawable method – InputStream stream = assets.open(region + "/“ + nextImageName +".png"); Drawable flag = Drawable.createFromStream(stream,nextImageName); flagImageView.setImageDrawable(flag);

3 String Resource 3 CS7030: Mobile App Development  strings.xml – Create string array – Africa Asia Europe North_America Oceania South_America  getResources().getStringArray(R.array. regionsList);

4 Animation Category 1. Tweened Animations – Scale animations (resize) – Rotate animations – Alpha animations (transparency) – Translate animations (move) 2. Frame-by-Frame Animations  An animation set may contain any combination of tweened animations 4 CS7030: Mobile App Development

5 Animation xml file 5 <translate android:fromXDelta="0" android:toXDelta="-5%p" android:duration="100"/> <translate android:fromXDelta="-5%p" android:toXDelta="5%p" android:duration="100" android:startOffset="100"/> <translate android:fromXDelta="5%p" android:toXDelta="-5%p" android:duration="100" android:startOffset="200"/> CS7030: Mobile App Development

6 Attributes of Animations 6 CS7030: Mobile App Development  fromXDelta : the view’s offset when the animation starts  toXDelta : the view’s offset when the animation ends  These attributes can have – Absolute values (in pixels) – A percentage of the animated View’s size – A percentage of the animated View’s parent’s size – -5%p indicates the View move to the left by 5% of the parent’s width – 5% indicates the View move to the right by 5% of the View’s width  duration : how long the animation lasts in milliseconds  startOffset : the number of milliseconds into the future at which an animation should begin

7 Load Tweened Animations 7  Create a folder called anim under res folder  Create new xml files in the anim folder. Add a set tag in the xml files: <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/decelerate_interpolator">  Add rotate, alpha, scale, or translate tag in the set tag.  Use AnimationUtils.loadAnimation to load the xml file, and then create an object of Animation – shakeAnimation = AnimationUtils.loadAnimation(this, R.anim.incorrect_shake);  startAnimation – flagImageView.startAnimation(shakeAnimation); CS7030: Mobile App Development

8 Handler 8  postDelayed receives Runnable as arguments to execute and a delay in milliseconds  Each Handler instance is associated with a single thread and that thread's message queue.  There are two main uses for a Handler: – to schedule messages and runnables to be executed as some point in the future – to enqueue an action to be performed on a different thread than your own. CS7030: Mobile App Development


Download ppt "Flag Quiz App 1 CS7030: Mobile App Development. assets Folder 2 CS7030: Mobile App Development  drawable folder – Image contents at the root level "

Similar presentations


Ads by Google