SlideShare a Scribd company logo
Material design screen transitions in android
SCREEN TRANSITIONS IN
ANDROID
GO FROM A TO B IN STYLE
Created by fromAndrei Diaconu Android Iasi
ME
CODE ON GITHUB
https://github.com/andreidiaconu/transitions-animate-demo
Presentation (with working video) at https://andreidiaconu.github.io/transitions-animate-demo
bit.ly/screen-anim
WHAT IS A SCREEN TRANSITION?
Material design screen transitions in android
 
WHAT ARE WE DOING TODAY?
8 Stages
STAGE 1 - DEFAULT ANIMATION
INITIAL SETUP
ACTIVITY A
grid.setOnItemClickListener(
  DetailsActivity1.start(GridActivity1.this, imageUrl);
)
ACTIVITY B
static void start(...,String imageUrl){
    intent = new Intent(...);
}
    
void onCreate(){
    Picasso
      .with(this)
      .load(imageUrl)
      .into(imageView);
}
 
STAGE 2 - MEASURING
Measure view in A
Send position to B
Resize the image in B
SEND POSITION
ACTIVITY A
void onItemClick(){
    DetailsActivity2.start(GridActivity2.this, imageUrl, view);
}
ACTIVITY B
static void start(..., View initialView){
    ...
    
    initialView.getGlobalVisibleRect(initialPosition);
    intent.putExtra("initialPosition", initialPosition);
    startActivity(intent);
}
 
STAGE 3 - NO DEFAULTS
Make B transparent
No default animations
Plan the animation
REMOVE DEFAULTS
STYLES.XML
<style name="AppTheme.Transparent">
</style>
  <item name="android:windowBackground">rtransparent</item>
  <item name="android:windowIsTranslucent">true</item>
STARTING ACTIVITY
from.overridePendingTransition(0,0);
RUN ONLY ONCE
void onCreate() {
    if (savedInstanceState==null){
        runAnimations();
    } 
}
 
STAGE 4 - START POSITION
Use translate and scale
Initial position for all views
WAIT FOR MEASUREMENTS
runAnimations(){
    imageView
        .getViewTreeObserver()
        .addOnPreDrawListener(
            boolean onPreDraw() {
                actuallyRunAnimations();
                removeOnPreDrawListener(this);
                return false;
            });
}
SET INITIAL POSITION
void actuallyRunAnimations(){
    Rect initialPosition = getIntent().getParcelableExtra(...);
    imageView.getGlobalVisibleRect(endPosition);
    //use initialPosition, endPosition
    imageView.setScaleY(...);
    imageView.setScaleX(...);
    imageView.setTranslationY(...);
    imageView.setTranslationX(...);
}
 
STAGE 5 - ANIMATE!
Animate image to final position
Fade background in
Bring other views from the sides
ANIMATE THINGS BACK TO NORMAL
imageView.animate()
        .scaleX(1)
        .scaleY(1)
        .translationX(0)
        .translationY(0)
        .setListener(
            void onAnimationEnd() {
                actionbar.animate()
                        .translationY(0)
                        .start();
            }
        ).start();
 
STAGE 6 - REVERSE
Override closing B
Animate everyhitng in reverse
Close B when on animation end
PREVENT FINISH()
@Override
public void finish() {
    if (canAnimateBack)
        runAnimationsBackwards();
    else
        super.finish();
}
DELAY FINISH()
imageView.animate()
    .scaleX(...)
    .scaleY(...)
    .translationX(...)
    .translationY(...)
    .setListener(
        void onAnimationEnd() {
            DetailsActivity6.super.finish();
            overridePendingTransition(0, 0);
        }
    ).start();
 
STAGE 7 - LOLLIPOP
Drop everything
Android 5 Screen Transitions
Define shared elements
STYLES.XML
<style name="AppTheme.Transitions">
    <item name = "windowActivityTransitions" >true</item>
</style>
LAYOUT B
<ImageView
    ...
    android:transitionName="shared_image"
    />
INTENT BUNDLE
ActivityOptionsCompat
    .makeSceneTransitionAnimation(from, initialView, "shared_image")
    .toBundle();
 
STAGE 8 - MAGIC
Content exit transition for A
Content enter transition for B
Detaults for exiting B and reentering A
EXIT + ENTER CONTENT TRANSITIONS
ACTIVTY A
getWindow().setExitTransition(new Explode());
ACTIVTY B
getWindow().setEnterTransition(new Slide());
 
COMPARISON
 
CODE ON GITHUB
https://github.com/andreidiaconu/transitions-animate-demo
Presentation (with working video) at https://andreidiaconu.github.io/transitions-animate-demo
bit.ly/screen-anim
THANK YOU!
QUESTIONS?
bit.ly/screen-anim

More Related Content

PDF
Few Things about Mobile GPU
PDF
Ionut grecu the soft stuff is the hard stuff. the agile soft skills toolkit
PPTX
Parallel & async processing using tpl dataflow
PDF
The bigrewrite
PPTX
Vlad zelinschi optimizing the critical rendering path
PPTX
Vlad Zelinschi - Embrace Native JavaScript (the anti-plugins talk) - Codecamp...
PPTX
Alex lakatos state of mobile web
PPTX
Flavius olaru logicless ui prototyping with node js
Few Things about Mobile GPU
Ionut grecu the soft stuff is the hard stuff. the agile soft skills toolkit
Parallel & async processing using tpl dataflow
The bigrewrite
Vlad zelinschi optimizing the critical rendering path
Vlad Zelinschi - Embrace Native JavaScript (the anti-plugins talk) - Codecamp...
Alex lakatos state of mobile web
Flavius olaru logicless ui prototyping with node js

Viewers also liked (20)

PPTX
Diaconu andrei list view vs recyclerview in android l
PDF
Kickstart your own freelancing career
PDF
Blind sizing
PDF
Iasi code camp 12 october 2013 marius ursache - sketching & prototyping
PPTX
Tiberiu Covaci - Fast, Faster: Async Asp.net
PPTX
Iasi code camp 12 october 2013 shadow dom - mihai bîrsan
PPTX
Raluca butnaru corina cilibiu the unknown universe of a product and the cer...
PPTX
Scale net apps in aws
PPTX
Sizing epics tales from an agile kingdom
PPTX
Remus Pereni - Remus Pereni - JavaScript, from dark ages to renaissance, the ...
PPTX
New Web
PDF
Ecma6 in the wild
PPTX
2015 dan ardelean develop for windows 10
PPT
Andrei prisacaru takingtheunitteststothedatabase
PDF
The case for continuous delivery
PPTX
Diana antohi me against myself or how to fail and move forward
PPTX
Stefan stolniceanu spritekit, 2 d or not 2d
PPTX
Agility and life
PDF
Cornel Fatulescu - Kanban
PPTX
Cloud powered search
Diaconu andrei list view vs recyclerview in android l
Kickstart your own freelancing career
Blind sizing
Iasi code camp 12 october 2013 marius ursache - sketching & prototyping
Tiberiu Covaci - Fast, Faster: Async Asp.net
Iasi code camp 12 october 2013 shadow dom - mihai bîrsan
Raluca butnaru corina cilibiu the unknown universe of a product and the cer...
Scale net apps in aws
Sizing epics tales from an agile kingdom
Remus Pereni - Remus Pereni - JavaScript, from dark ages to renaissance, the ...
New Web
Ecma6 in the wild
2015 dan ardelean develop for windows 10
Andrei prisacaru takingtheunitteststothedatabase
The case for continuous delivery
Diana antohi me against myself or how to fail and move forward
Stefan stolniceanu spritekit, 2 d or not 2d
Agility and life
Cornel Fatulescu - Kanban
Cloud powered search
Ad

Similar to Material design screen transitions in android (8)

PPTX
Material Design Android
PPT
Getting the Magic on Android Tablets
PDF
Material Design Demytified - Ran Nachmany, Google
PDF
Learn How to Animate your Android App
PDF
Android Lollipop - Webinar vom 11.12.2014
PPTX
What's New in Android
PPT
Getting the Magic on Android Tablets
KEY
Design Patterns for Tablets and Smartphones
Material Design Android
Getting the Magic on Android Tablets
Material Design Demytified - Ran Nachmany, Google
Learn How to Animate your Android App
Android Lollipop - Webinar vom 11.12.2014
What's New in Android
Getting the Magic on Android Tablets
Design Patterns for Tablets and Smartphones
Ad

More from Codecamp Romania (15)

PDF
Cezar chitac the edge of experience
PPTX
Business analysis techniques exercise your 6-pack
PPTX
Bpm company code camp - configuration or coding with pega
PDF
Codecamp2015 pimp yourpipeline-saade-jens-1.1
PPTX
Code camp iasi silviu niculita - machine learning for mere mortals with azu...
PPTX
About leadership
PPTX
Business analysis techniques exercise your 6-pack
PPTX
Bpm company code camp - configuration or coding with pega
PPT
Andrei prisacaru takingtheunitteststothedatabase
PPTX
The bigrewrite
PDF
The case for continuous delivery
PPTX
Stefan stolniceanu spritekit, 2 d or not 2d
PPTX
Sizing epics tales from an agile kingdom
PPTX
Scale net apps in aws
Cezar chitac the edge of experience
Business analysis techniques exercise your 6-pack
Bpm company code camp - configuration or coding with pega
Codecamp2015 pimp yourpipeline-saade-jens-1.1
Code camp iasi silviu niculita - machine learning for mere mortals with azu...
About leadership
Business analysis techniques exercise your 6-pack
Bpm company code camp - configuration or coding with pega
Andrei prisacaru takingtheunitteststothedatabase
The bigrewrite
The case for continuous delivery
Stefan stolniceanu spritekit, 2 d or not 2d
Sizing epics tales from an agile kingdom
Scale net apps in aws

Recently uploaded (20)

PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Electronic commerce courselecture one. Pdf
PDF
Modernizing your data center with Dell and AMD
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Cloud computing and distributed systems.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
A Presentation on Artificial Intelligence
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Unlocking AI with Model Context Protocol (MCP)
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Electronic commerce courselecture one. Pdf
Modernizing your data center with Dell and AMD
NewMind AI Monthly Chronicles - July 2025
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
The Rise and Fall of 3GPP – Time for a Sabbatical?
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Spectral efficient network and resource selection model in 5G networks
Cloud computing and distributed systems.
Per capita expenditure prediction using model stacking based on satellite ima...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Encapsulation_ Review paper, used for researhc scholars
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Understanding_Digital_Forensics_Presentation.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
A Presentation on Artificial Intelligence
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Unlocking AI with Model Context Protocol (MCP)

Material design screen transitions in android