SlideShare a Scribd company logo
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?
 
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

Viewers also liked

Blind sizing
Blind sizingBlind sizing
Blind sizing
sowmya_k
 
Iasi code camp 12 october 2013 marius ursache - sketching & prototyping
Iasi code camp 12 october 2013  marius ursache - sketching & prototypingIasi code camp 12 october 2013  marius ursache - sketching & prototyping
Iasi code camp 12 october 2013 marius ursache - sketching & prototyping
Codecamp Romania
 
Tiberiu Covaci - Fast, Faster: Async Asp.net
Tiberiu Covaci - Fast, Faster: Async Asp.netTiberiu Covaci - Fast, Faster: Async Asp.net
Tiberiu Covaci - Fast, Faster: Async Asp.net
Codecamp Romania
 
Iasi code camp 12 october 2013 shadow dom - mihai bîrsan
Iasi code camp 12 october 2013   shadow dom - mihai bîrsanIasi code camp 12 october 2013   shadow dom - mihai bîrsan
Iasi code camp 12 october 2013 shadow dom - mihai bîrsan
Codecamp Romania
 
Remus Pereni - Remus Pereni - JavaScript, from dark ages to renaissance, the ...
Remus Pereni - Remus Pereni - JavaScript, from dark ages to renaissance, the ...Remus Pereni - Remus Pereni - JavaScript, from dark ages to renaissance, the ...
Remus Pereni - Remus Pereni - JavaScript, from dark ages to renaissance, the ...
Codecamp Romania
 

Viewers also liked (20)

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

Similar to Material design screen transitions in android

The not so short
The not so shortThe not so short
The not so short
AXM
 
14multithreaded Graphics
14multithreaded Graphics14multithreaded Graphics
14multithreaded Graphics
Adil Jafri
 

Similar to Material design screen transitions in android (20)

Android Oreo
Android OreoAndroid Oreo
Android Oreo
 
ReactiveCocoa - TDC 2016
ReactiveCocoa - TDC 2016ReactiveCocoa - TDC 2016
ReactiveCocoa - TDC 2016
 
FiiPractic 2015 - Adroid Pro - Day 1 - UI Day
FiiPractic 2015 - Adroid Pro - Day 1 - UI DayFiiPractic 2015 - Adroid Pro - Day 1 - UI Day
FiiPractic 2015 - Adroid Pro - Day 1 - UI Day
 
How To Build iOS Apps Without interface Builder
How To Build iOS Apps Without interface BuilderHow To Build iOS Apps Without interface Builder
How To Build iOS Apps Without interface Builder
 
Game development with Cocos2d
Game development with Cocos2dGame development with Cocos2d
Game development with Cocos2d
 
Advancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and GesturesAdvancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and Gestures
 
Develop Denver 2014: Building Physical Video Games
Develop Denver 2014: Building Physical Video GamesDevelop Denver 2014: Building Physical Video Games
Develop Denver 2014: Building Physical Video Games
 
662305 LAB13
662305 LAB13662305 LAB13
662305 LAB13
 
Building a camera in a program | Computer Graphics
Building a camera in a program | Computer GraphicsBuilding a camera in a program | Computer Graphics
Building a camera in a program | Computer Graphics
 
The not so short
The not so shortThe not so short
The not so short
 
Leaving Interface Builder Behind
Leaving Interface Builder BehindLeaving Interface Builder Behind
Leaving Interface Builder Behind
 
004
004004
004
 
iphonedevcon 2010: Cooking with iAd
iphonedevcon 2010:  Cooking with iAd iphonedevcon 2010:  Cooking with iAd
iphonedevcon 2010: Cooking with iAd
 
QXCameraKit
QXCameraKitQXCameraKit
QXCameraKit
 
Game development via_sprite_kit
Game development via_sprite_kitGame development via_sprite_kit
Game development via_sprite_kit
 
Dip iit workshop
Dip iit workshopDip iit workshop
Dip iit workshop
 
Building a Native Camera Access Library - Part I.pdf
Building a Native Camera Access Library - Part I.pdfBuilding a Native Camera Access Library - Part I.pdf
Building a Native Camera Access Library - Part I.pdf
 
14multithreaded Graphics
14multithreaded Graphics14multithreaded Graphics
14multithreaded Graphics
 
Standford 2015 week7: 1. Unwind Segues, Alerts, Timers, View Animation 2. Dyn...
Standford 2015 week7: 1. Unwind Segues, Alerts, Timers, View Animation 2. Dyn...Standford 2015 week7: 1. Unwind Segues, Alerts, Timers, View Animation 2. Dyn...
Standford 2015 week7: 1. Unwind Segues, Alerts, Timers, View Animation 2. Dyn...
 
Basics cocos2d
Basics cocos2dBasics cocos2d
Basics cocos2d
 

More from Codecamp Romania

Business analysis techniques exercise your 6-pack
Business analysis techniques   exercise your 6-packBusiness analysis techniques   exercise your 6-pack
Business analysis techniques exercise your 6-pack
Codecamp Romania
 
Bpm company code camp - configuration or coding with pega
Bpm company   code camp - configuration or coding with pegaBpm company   code camp - configuration or coding with pega
Bpm company code camp - configuration or coding with pega
Codecamp Romania
 
Andrei prisacaru takingtheunitteststothedatabase
Andrei prisacaru takingtheunitteststothedatabaseAndrei prisacaru takingtheunitteststothedatabase
Andrei prisacaru takingtheunitteststothedatabase
Codecamp Romania
 
The case for continuous delivery
The case for continuous deliveryThe case for continuous delivery
The case for continuous delivery
Codecamp Romania
 
Stefan stolniceanu spritekit, 2 d or not 2d
Stefan stolniceanu   spritekit, 2 d or not 2dStefan stolniceanu   spritekit, 2 d or not 2d
Stefan stolniceanu spritekit, 2 d or not 2d
Codecamp Romania
 
Sizing epics tales from an agile kingdom
Sizing epics   tales from an agile kingdomSizing epics   tales from an agile kingdom
Sizing epics tales from an agile kingdom
Codecamp Romania
 

More from Codecamp Romania (15)

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

Recently uploaded

Recently uploaded (20)

"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 

Material design screen transitions in android