Android week 3 - Android Animations

  • View

  • Download

Embed Size (px)


Join Live Course at Module Goals: In this part we will learn different Android features like ActionBar, Notifications, Playing Media Files etc. Also we will learn how to use Animations in Android to make our Apps more beautiful and interactivie. Options Menu Using Action Bar in Android Notifications Shared Preferences Media Player Video Player Animation in Android Tween Animations Alpha Scale Translate Rotate CrossFading Animations CardFlip Animations

Text of Android week 3 - Android Animations

  • 1.Android Technology Day Three

2. Agenda Options Menu Notifications Designing and Creating Notifications Shared Preferences Preference Screens Media Player 3. Agenda Animation in Android Tween Animations Alpha Scale Translate Rotate Cross Fading Animations Card Flip Animations 4. Options Menu Above v-2.3 they are shown in Navigation drawer Override onCreateOptionsMenu() method to define your custom menu Below V-2.3 Above V-2.3 5. Notifications Notification is a message that you can display outside your application UI User can expand the notification bar and trigger another activity by clicking on notification. 6. Designing Notifications Source 7. Creating a Notification 1. We design our notification with NotificationCompat.Builder class 2. Defining the action of notification with PendingIntent 3. Firing the notification with NotificationManager 8. Preferences Screen (Easy Way) Used to save key-value pairs of primitive data types SharedPreferences settings = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); String myNameIs = settings.getString("name", ""); 9. Shared Preferences (Default Way) Saving SharedPreferences prefs = getSharedPreferences(details", MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putString(name", Whatever); editor.commit(); Retreiving SharedPreferences settings = getSharedPreferences("details", MODE_PRIVATE); String myNameIs = settings.getString(name", No name found); You should ask, where should we use this? 10. Media Player and Sound Pool MediaPlayer class can be used to control playback of audio/video files and streams. Use SoundPool when you have media files of very small duration. 11. Animations 12. Animations Androids Animation Framework provides two types of animations. Frame animation Tween animation 13. Frame Animation An XML based animation that shows a series of images in order at regular intervals (like a film) Steps: 1. Create an XML file inside drawable folder 2. Copy all the images inside the drawable folder 14. Frame Animation XML Code 15. Tween Animation An XML based animation that performs transitions such as: Rotating Fading Moving Stretching Multiple transitions can be performed by using the tag. is a container of other animations 16. Fading Important attributes: android:fromAlpha android:toAlpha Here Alpha represents Opacity of the object whose value can lie: 0.0 < alpha