Animating a Floating Action Button Activity Transition - android

The Material Design Guidelines suggest that you transition a floating action button into a new Activity, after you click on the button.
Example Video from Guidelines
I tried to animate this with Activity transition, as intoduced in API 21 (Lollipop) but I can't find a way to transform from the color of the button to the color of the toolbar. (I used this Floating Action Button)
Obviously, the example isn't an actual demo running on android, but the device that is displayed is clearly a smartphone. Therefore there has to be a way to code this kind of transition, or else Google would not have added this on their Guidelines, would they?
Can I use Activities to achieve this or do I have to use Fragments?

As FloatingActionButton descends from ImageButton and adds only a few new methods,you can use setBackgroundColor() of ImageButton to change its background.

Related

Mixing bottom app bar and floating action button (FAB)

I want to use BottomNavigation and FloatingActionButton at the same time in Android and there is nothing like this in google material components and also I didn't find any third party library which implements something like this. Attached GIF demonstrate what I want to implement. In fact I want a bottom navigation that one of its tabs has a FAB which placed on the navigation bar and the FAB disappears when another tab is selected.
See the attached image here.
You won't find a Material component for the layout in your example since it's counter to the Material Design Spec.
Floating Action Button (FAB) represents the primary action of a screen
The example would provide multiple "primary" interactions since its mixed with navigation. I would not recommend using the FAB in the context of a bottom navigation bar. Instead, separate them visually for the user's benefit by moving the FAB up and to the right of the page. Here are the Material Docs for Extending the FAB
Now you don't have to follow the Material Spec BUT you shouldn't expect pre-built Material components to ignore it.

How animate icon inside floating action button

I want to create animation for my fab like this example in material design principle, I realized that icon inside fab has 2 animation. One that rotate share icon and another is alpha animation simultaneity. after that another icon replaced. but when I create animation set for this goal, whole fab rotated and disappeared, but I want that icon inside fab take this animation. How can I create this animation? thanks
The best way to achive that is create a Custom Floating action button class and Override your setImageDrawable method, doing the translation animation there. Also you can modify your onDraw method to add an animation to your FloatingActionButton
You have to use a third-party library to achieve this result. Take a look here It is important to notice that it is possible to implement your own way but you would be kind of "reinventing the wheel".
If you want to do this anyway, you can create several FABs and change visibilities and move them with simple animations.

Android : Difference FloatingActionButton and normal button

I have tried demo FloatingActionButton. I don't see real differences why I should change from normal button class to FloatingActionButton because if I want to make round button, I can try this tutorial:make circular button
As definition of Android Document:
Floating action buttons are used for a special type of promoted
action. They are distinguished by a circled icon floating above the UI
and have special motion behaviors related to morphing, launching, and
the transferring anchor point.
Floating action buttons come in two sizes: the default and the mini.
The size can be controlled with the fabSize attribute.
I think everything here I can implement easily in normal button such as size, circle, above UI. Just one thing I don't understand:
special motion behaviors related to morphing, launching, and the
transferring anchor point
I don't really know this. What does it mean about morphing lauching and transfering anchor point. Please explain for me.
thanks :)
There is a nice article about Floating Action Buttons at Google's Material Design Guidelines: https://www.google.com/design/spec/components/buttons-floating-action-button.html There is a lot of examples about how you can (and should and shouldn't) use the Floating Action Button at activity transitions and how it can be used to create nice, meaningful and logical animations.
If you use the correct Floating Action Button (the one from the Support Design library) together with CoordinatorLayout, it will also take care of Snackbars. When a Snackbar appears, the Floating Action Button will move up in order not to be covered by the Snackbar. You can check it out here: http://android-developers.blogspot.cz/2015/05/android-design-support-library.html

Hide the Menu Button in new API21 Toolbar

I'm upgrading my app to support new Google APIs.
I've been playing for a while with new Toolbars but I still can't get how to make the menu button disappears when a Drawer Layout is opened.
Reference from the Material Design page (I'm trying to achieve the one on the right):
Radial Action
I'm not trying to "replace" the button like the example but to hide it temporary with an animation.
Any suggestion would be much appreciated! Thanks

Moving a view left of the screen

My android app UI have two parts- a menu bar (blue color) and content area (gray color).
Here red is the device screen.
The menu bar should open from left to right whene the hamburger menu is clicked.
I tried with ViewSwitcher but that shows only one view at a time.
What is the right method to implement it?
UPDATE: I am looking for the solution for API level 10 onwards.
In the newest version of the ADT you can select Navigation Drawer as navigation type when you create a new Activity. This automatically implements this type of navigation for you.
Alternatively, check out this tutorial: http://developer.android.com/training/implementing-navigation/nav-drawer.html
If you are happy with the navigation bar overlaying the content, then use the navigation drawer as suggested.
Alternatively check out:
https://play.google.com/store/apps/details?id=com.desarrollodroide.repos
There are many open source libraries that you can pick and test, and then decide which one to grab the code for.

Categories

Resources