Android Jetpack
UI Components
Palette
Layout
Fragment
Emoji
Animation & transitions
Jetpack Components
introduction
Foundation
Architecture
Behavior
UI
Foundation Components
Android KTX
AppCompat
Auto
Benchmark
Multidex
Security
Test
TV
Wear OS by Google
Architecture Components
Data Binding
Lifecycles
LiveData
Navigation
Paging
Room
ViewModel
WorkManager
Behavior Components
CameraX
Download manager
Media & playback
Notifications
Permissions
Preferences
Sharing
Slices

Animation & transitions



Animation & transitions, Android Jetpack UI Components, Move widgets and transition between screens


Android includes different animation APIs depending on what type of animation you want

  • Animate bitmaps
  • Animate UI visibility and motion
  • Animate layout change
  • Animate between activities

Animate bitmaps

Animate a bitmap graphic such as an icon or illustration, use the drawable animation APIs. Android provides a couple options for animating drawables.


ClassDescription
AnimationDrawableTo create frame-by-frame animations, defined by a series of Drawable objects, which can be used as a View object's background.
AnimatedVectorDrawableAnimates properties of VectorDrawable with animations defined using ObjectAnimator or AnimatorSet.

AnimationDrawable Example


To create a frame-by-frame animation is to define the animation in an XML file, placed in the res/drawable/ folder, and set it as the background to a View object.


An AnimationDrawable defined in XML consists of a single element and a series of nested tags. Each item defines a frame of the animation and its duration.


spin_animation_ad.xml file in res/drawable/ for AnimationDrawable example



 <!-- Animation frames are spin1.png through spin6.png
     files inside the res/drawable/ folder with file name as spin_animation_ad.xml-->
<?xml version="1.0" encoding="utf-8"?>
<animation-list android:id="@+id/selected"
    android:oneshot="false"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/n1" android:duration="150" />
    <item android:drawable="@drawable/n2" android:duration="150" />
    <item android:drawable="@drawable/n3" android:duration="150" />
    <item android:drawable="@drawable/n4" android:duration="150" />
    <item android:drawable="@drawable/n5" android:duration="150" />
</animation-list>

Code to play this AnimationDrawable


    ImageView imgView = (ImageView)findViewById(R.id.spin_image);
    imgView.setBackgroundResource( R.drawable.spin_animation_ad);

    // Get the background, which has been compiled to an AnimationDrawable object.
    AnimationDrawable objAnimationDrawable = (AnimationDrawable) imgView.getBackground();

    // Start the animation
    objAnimationDrawable.start();



The Sample Project is available for Download from GitHub.



Animation & transitions

Animation & transitions, Android Jetpack UI Components, Move widgets and transition between screens

posted on 2019-10-25 08:04:17 - Android Jetpack Tutorials


Emoji

Emoji, Android Jetpack UI Components, Enable an up-to-date emoji font on older platforms

posted on 2019-10-25 08:03:43 - Android Jetpack Tutorials


Fragment

Fragment, Android Jetpack UI Components, A basic unit of composable UI

posted on 2019-10-25 08:03:24 - Android Jetpack Tutorials


Prompt Examples

ChatGPT Prompt Examples

posted on 2023-06-21 22:37:19 - ChatGPT Tutorials


Use Cases

Chat GPT Key Use Cases

posted on 2023-06-21 21:03:17 - ChatGPT Tutorials


Prompt Frameworks

Prompt Frameworks

posted on 2023-06-21 19:33:06 - ChatGPT Tutorials