Feed Buzzard
  • General
  • Tech
  • World Tech
  • World Tech Code
  • Wearable Tech
  • Pokemon
  • About Us
    • Terms & Conditions
    • Privacy Policy
  • Contact
No Result
View All Result
  • General
  • Tech
  • World Tech
  • World Tech Code
  • Wearable Tech
  • Pokemon
  • About Us
    • Terms & Conditions
    • Privacy Policy
  • Contact
No Result
View All Result
Feed Buzzard
No Result
View All Result
Home World Tech

How to animate floating action button using android activity transition? –

Gordon James by Gordon James
January 9, 2021
in World Tech
0
0
SHARES
10
VIEWS
Share on FacebookShare on Twitter

Development issue/problem:

I plan to implement something similar in one of my projects, but I don’t understand the concept, nor does such a tutorial exist, especially since you don’t see it very often. So it seems. Click here to go to the source.

Hardware animation (to move the button) and opening circle
(to give the impression that the button has exploded).

If you find a better answer to the following question, you can place it here.

How can I solve this problem?

Solution 1:

It’s an old question, but it’s still an interesting one. Here’s how I implemented it:

The first thing to do is to create two ViewGroups, which are called scenes in the api transition. The first scene contains views before the transition, the second scene contains views after the transition. Then simply replace the first scene with the second and make a transition that describes how the views of the first scene change into the second, as well as how the views of the first scene disappear and the views of the second scene appear.

Give here a description of the image

In this example there is a problem with the Fab button, because this is the only image that is animated from the white part of the main screen of the scene. The scenes are therefore in full screen with an indentation at the top corresponding to the height of Monday’s blue title.

By default, all transitions are listed here, except those with a yellow background. The yellow background display
appears in the second scene with the circular aperture animation. And it disappears with a circular collapse animation. There’s no such animation by default, so I wrote mine:

import android.animation.animator;
import android.animation.AnimatorListenerAdapter;
import android.support.transition.steel;
import android.transition.visible;
import android.view.view;
import android.view.ViewAnimationUtils;
import android.view.viewGroup ;

public class CircularTranslation extends visibility {

@Public Animator
onAppear(ViewGroup sceneRoot, View View, TransitionValues startValues, TransitionValues endValues) {
int startRadius = 0;
int endRadius = (int) Math.hypot(view.getWidth(), view.getHeight());
Animator reveal = ViewAnimationUtils.createCircularReveal(view, view.getWidth() / 2, view.getHeight() / 2, startRadius, endRadius);
// Make the view invisible until the animation actually starts
view.setAlpha(0);
reveal.addListener(new AnimatorListenerAdapter() {
@Override
public blank atAnimationStart(Animator animation) {
view.setAlpha(1);
}
});
return reveals;
}

@Override
public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) {
int endRadius = 0 ;
int startRadius = (int) Math.hypot(view.getWidth(), view.getHeight()));
Animator reveal = ViewAnimationUtils.createCircularReveal(view, view.getWidth() / 2, view.getHeight() / 2, startRadius, endRadius);
return reveal;
}
}

The full code is here:

import android.os.bundle;import android.support.annotation.NonNull;import android.support.design.widget.floatingActionButton;import android.support.transition.ArcMotion;import android.transition.changeBounds.import android.support.transition.Fade;import android.transition.Scene.import android.support.scene;import android.support.transition.scene;import android.support.transition.slide;import android.support.transition.transition.transition.ListenerAdapter; import android.support.transitionManager; import android.support.transition.Fade; import android support.transition.Scene; import android support.transition.Scene; import android support.transitionSet; import android support.v7.app.App.AppCompatActivity; import android.view.Gravity; import android.view.view; import android.viewGroup;

The MainActivity public class expands AppCompatActivity {

closed ViewGroup mSceneRoot ;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.active_main);
setSupportActionBar(findViewById(R.id.toolbar)));
mSceneRoot = findViewById(R.id.sceneRoot);
// show scene1 without animation
showScene1(false);
}

private void showScene1(boolean animation) {
ViewGroup root = (ViewGroup) getLayoutInflater().inflate(R.layout.scene1, null);
FloatingActionButton fab = root.findViewById(R.id.fab);
fab.setOnClickListener(v -> {
showScene2();
});
Scene scene = new Scene(mSceneRoot, root);
Transition = animated? getScene1Transition(): null;
TransitionManager.go(scene, transition);
}

private void showScene2() {
ViewGroup root = (ViewGroup) getLayoutInflater().inflate(R.layout.scene2, null);
View btnBack = root.findViewById(R.id.btnCancel);
btnBack.setOnClickListener(v -> {
showScene1(true);
})

Scene scene = new scene (mSceneRoot, root);
Transition = getScene2Transition();
TransitionManager.go(scene, transition);
}

private Transition getScene2Transition() {
TransitionSet set = new TransitionSet() ;

//fab changes PositionChangeBounds changeTransform = new ChangeBounds();changeTransform.addListener(new TransitionListenerAdapter() {@Overrider void onTransitionEnd(@NonNull Transition))) { //hide fab button at the end of animationmSceneRoot.findViewById(R.id.fab).setVisibility(View.INVISIBLE);}.}); changeTransform.addTarget(R.id.fab); changeTransform.setDuration(300); //fab arcMotion arcMotion = new ArcMotion(); arcMotion.setMaximumAngle(45); arcMotion.setMinimumHorizontalAngle(90); arcMotion.setMinimumVerticalAngle(0); changeTransform.setPathMotion(arcMotion); set.addTransition(changeTransform);

//bg cycle open animation
CircularRevealTransition crt = new CircularRevealTransition();
crt.addTarget(R.id.yellowBG);
crt.setStartDelay(200);
crt.setDuration(600);
set.addTransition(crt) ;

The // buttons appear
fade = new Fade();
fade.addTarget(R.id.btnBegin);
fade.addTarget(R.id.btnCancel);
fade.addTarget(R.id.text);
fade.setStartDelay(600);
set.addTransition(fade) ;

// buttons in the left column slide left
slide = new slide (Gravity.LEFT);
slide.addTarget (R.id.slideLeftContainer); set
.addTransition(slide); column
// buttons in the right column slide right
slide2 = new slide (Gravity.RIGHT);
slide2.addTarget(R.id.slideRightContainer);
set.addTransition(slide2);
return set;
}

private Transition getScene1Transition() {
TransitionSet set = new TransitionSet() ;

// Hide buttons in scene2
fade = new Fade();
fade.addTarget(R.id.btnBegin);
fade.addTarget(R.id.btnCancel);
fade.addTarget(R.id.btnCancel);
set.addTransition(fade) ;

// The circular collapse animation starts
CircularRevealTransition crt = new CircularRevealTransition();
crt.addTarget(R.id.yellowBG);
crt.setDuration(600);
set.addTransition(crt) ;

//
ChangeBounds changeTransform = new ChangeBounds();
changeTransform.addTarget(R.id.fab);
changeTransform.setDuration(300);
changeTransform.setStartDelay(500);
//arcPath
arcMotion arcMotion = new ArcMotion();
arcMotion.setMaximumAngle(45);
arcMotion.setMinimumHorizontalAngle(90);
arcMotion.setMinimumVerticalAngle(0);
changeTransform.setPathMotion(arcMotion);
set.addTransition(changeTransform) ;

//
slide = new slide (Gravity.LEFT);
slide.addTarget (R.id.slideLeftContainer);
slide.setStartDelay(500);
setTransition(slide) ;

// the column of the right button is placed on the right side
Slide2 = new Slide(Gravity.RIGHT);
slide2.addTarget(R.id.slideRightContainer);
slide2.setStartDelay(500);
set.addTransition(slide2);
return set;
}

}

activity_main.xml :

Scene 1.xml :

Scene 2.xml :

button.xml :

Values.xml :

Transition test

#3F51B5
#303F9F
#FF4081

16dp
200dp
132dp

Solution 2:

I think what you’re looking for makes sense.

On devices with pre-installed Lollipop this can be done with the ActivityOptionsCompatible wizard.

Some useful links that may help you:

Good luck!

Related Tags:

materialcontainertransform,android expand floating action button,floating animation android,android fab to full screen,custom fab icon android,extended floating action button,floating action button animation flutter,floating button with animation,animated fab button with more options,movable floating action button android,custom floating action button android,what is floating action button in whatsapp,android floating action button menu,floating action button android,pressedtranslationz,positioning floating action button,floating action button android github,floating action button ios,floating action button android example,add floating layout android,how to use floating action button in androidx,change floating action button color,android floating action button icon color,search floating action button,coordinatorlayout floatingactionbutton,layout anchor android,whatsapp floating button android,floating action button example in android,circular floating action menu android github,floating bubble animation android,android floating action button animation,movable floating action button android github,floating-button animation android github,android fab show/hide animation

Total
0
Shares
Share 0
Tweet 0
Pin it 0
Share 0
Gordon James

Gordon James

James Gordon is a content manager for the website Feedbuzzard. He loves spending time in nature, and his favorite pastime is watching dogs play. He also enjoys watching sunsets, as the colors are always so soothing to him. James loves learning about new technology, and he is excited to be working on a website that covers this topic.

Related Posts

Blockchain Conference in Poland Showcases New Solutions to Problems in Enterprise Logistics
World Tech

Blockchain Conference in Poland Showcases New Solutions to Problems in Enterprise Logistics

December 15, 2022
World Tech

Rockstar Games Brings GTA to The Metaverse

October 20, 2022
World Tech

Ways Technology Is Changing The World Of Education

September 21, 2022
Next Post

Add bigger margin to EditText in lertDialog –

How to measure height, width and distance of object using camera? –

Fixing Error Fatal: Origin does not appear to be a Git Repository

No Result
View All Result

Recommended

Myths and Misconceptions About Joint Pain

Myths and Misconceptions About Joint Pain

6 hours ago
The Spider Veins Facts that Every Individual Ought to Know

The Spider Veins Facts that Every Individual Ought to Know

6 hours ago

5 Benefits of Telehealth That You Should Understand

16 hours ago
openai gpt3 dallmiddotdouglas mit technologyreview

Why GPT-3 is so Impressive – and Why it’s Also Worrying

24 hours ago

Categories

  • Fitness Trackers
  • General
  • Latest
  • Pokemon
  • Tech
  • Technology and Computing
  • Wearable Tech
  • World Tech
  • World Tech Code

Recent Posts

  • Myths and Misconceptions About Joint Pain January 30, 2023
  • The Spider Veins Facts that Every Individual Ought to Know January 30, 2023
  • 5 Benefits of Telehealth That You Should Understand January 30, 2023
  • Why GPT-3 is so Impressive – and Why it’s Also Worrying January 29, 2023

Categories

  • Fitness Trackers
  • General
  • Latest
  • Pokemon
  • Tech
  • Technology and Computing
  • Wearable Tech
  • World Tech
  • World Tech Code

© 2022 FeedBuzzard.com

No Result
View All Result
  • General
  • Tech
  • World Tech
  • World Tech Code
  • Wearable Tech
  • Pokemon
  • About Us
    • Terms & Conditions
    • Privacy Policy
  • Contact

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT