I am trying to understand what animation is used in the Google Maps application.
The part I am trying to understand is when you click on the textbox in the toolbar. The layout animates to present a completely new screen with a few items sliding in from the bottom.
How is this done? Is it a bottom sheet becoming visible? Is it a new activity with shared element transitions?
That is called activity transitions. Where you choose which layouts should been moved to a second activity. See also the official documentation about animations: http://developer.android.com/training/material/animations.html#Transitions
Another good point to start it the video talk from the Google Developers: https://www.youtube.com/watch?v=RhiPJByIMrM
Basically you need to modify the style like here:
<style name="BaseAppTheme" parent="android:Theme.Material">
<!-- enable window content transitions -->
<item name="android:android:windowActivityTransitions">true</item>
<!-- specify enter and exit transitions -->
<item name="android:windowEnterTransition">#transition/explode</item>
<item name="android:windowExitTransition">#transition/explode</item>
<!-- specify shared element transitions -->
<item name="android:windowSharedElementEnterTransition">
#transition/change_image_transform</item>
<item name="android:windowSharedElementExitTransition">
#transition/change_image_transform</item>
</style>
You also need to specify a special attribute called android:transitionName to say the system that you want to move that from one activity to a second one.
This is a single activity that has 2 modes: map mode and input+list mode.
You can have a FrameLayout and within have the map root view (visible) and the input root view (gone). When you want to open the list, you make it visible and use ViewAnimation to animate it going up.
A better approach is to break these 2 main views into 2 fragments, and animate the fragment.
The example that you are talking about is basically Google Places AutoComplete Api.
Please follow the link for the same :
https://developers.google.com/places/android-api/autocomplete
Related
After signing in with the googleSignIn() method in flutter, there is an undesired transition appearing on the screen (Example : https://i.stack.imgur.com/CWIhL.gif).
This is not a glitch for the Android emulator, it also happens on my physical device.
The only solution I found was to add the following line to the styles.xml to disable the Transition :
<item name="android:windowAnimationStyle">#null</item>
However, I do not want to disable the animations for the whole app. How can I only disable it for the Login Screen ? I do not know what side effects may occur disabling all windowAnimationStyle for the whole app ?
You might be able to create a style for an individual view or a theme for a particular activity or view hierarchy. An example of this is given in the following link: https://gist.github.com/cesarferreira/38bf26a68317ac15f1dc
<!-- Developer should create a style -->
<style name="noAnimTheme" parent="android:Theme">
<item name="android:windowAnimationStyle">#null</item>
</style>
<!-- Then in manifest set it as theme for activity or whole application. -->
<activity android:name=".ui.ArticlesActivity" android:theme="#style/noAnimTheme">
</activity>
More information on Styles and Themes are given here: https://developer.android.com/guide/topics/ui/look-and-feel/themes#Styles
I added a toolbar item in my content page:
<ContentPage.ToolbarItems>
<ToolbarItem IconImageSource="icon_dropdown.png"/>
</ContentPage.ToolbarItems>
What I want to have is when a user clicks on the toolbar item, a menu pops down like this. Animated in a way where it slides down revealing the content/menu items.
I've been searching online but the keywords being searched always takes me to spinner, and being new to C# and Xamarin Forms, I am unsure if a spinner is still what I want to achieve something like this because a spinner looks more of a dialog box.
Sample image of what I'm trying to do that I've photoshopped
Any help is highly appreciated. Thanks.
I did some investigation, and find a way to change the position of the overflow popmenu by theme(code attached at the end in case you need it), but unable to change the width to match the whole screen, not sure if Android made some limitations in menu.
If you need a drop down list exact the same of your picture, spinner may not be a perfect choice either, you'd better create a new activity that overlays origin activity and customize the new activity layout, but it's not recommended considering performance. Also, you can find something in an earlier post to see if it gives you any idea.
add a new style:
<style name="OverflowMenuStyle" parent="#style/ThemeOverlay.AppCompat.Light">
<item name="overlapAnchor">false</item><!--not overlay the toolbar-->
<!--<item name="android:dropDownWidth">10dp</item> not work-->
<!--<item name="android:maxWidth">400dp</item> not work-->
<item name="android:paddingRight">0dp</item>
<!--dropDownVerticalOffset is the property you want to avoid overlay the toolbar-->
<item name="android:dropDownVerticalOffset">4dp</item>
<item name="android:dropDownHorizontalOffset">0dp</item>
<item name="android:popupBackground">#BFBFBF</item>
</style>
Android Resource layout folder's Toolbar.xml, change popupTheme to:
android:popupTheme="#style/OverflowMenuStyle"
add an item in MainTheme.Base style:
<item name="actionOverflowMenuStyle">#style/OverflowMenuStyle</item>
I put together a very simple app that uses shared element transitions when starting an activity with Dialog theme (source code on github).
I got the following result:
As you can see there are 2 problems with the transition/animation:
The animation is only visible in the area of the dialog activity so it clips and looks ugly.
There is no transition/animation when I tap outside the activity to
go back.
How can I fix these problems? Any help would be appreciated.
EDIT: After Quanturium's answer I did the following things to get it working:
Use the following theme instead of a Dialog theme:
<style name="AppTheme.Transparent" parent="AppTheme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
Use a CardView as the background for Dialog look and for rounded corners and shadows.
Call finishAfterTransition(); when user taps outside the CardView.
Now it looks like this (code), the CardView needs refining to better match the Dialog, but it's working at least.:
An activity transition works like this. When you start your second activity, it is displayed on top of your first one with a transparent background. The shared elements are positioned the same way they are on the first activity and then animated to the correct position specified on the second activity.
In your case you are using android:theme="#style/Theme.AppCompat.Dialog" which mean the size of the second activity's drawing area is smaller than the one from the first activity. This explains the clipping and the no transition when clicking outside.
What you want to do is get rid of that theme, and implement your own layout with a dark background / shadow in order to be able to execute your smooth transition.
In my application I have a main activity with a GoogleMap fragment inside it. The map often moves its camera and draws markers and polylines without a direct user interaction (i.e to follow a target).
The problem occurs when I start other translucent/transparent activities on top of that main one. I cannot use dialogs, views of fragments, unfortunately I have to use only activities. So I declared their style as:
<style name="AppTheme.Transparent" parent="AppTheme">
<item name="android:windowNoTitle">true</item>
<item name="android:background">#android:color/transparent</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowIsTranslucent">true</item>
</style>
These activities have some views placed on top of a semi-transparent black background, so one can see the map behind them. The problem is that the map drawing is not updated at all while behind these activities, despite the fact that the code that, for example, move the camera actually runs (I can see it from logs or debugging). The map drawing is updated correctly only after (and immediately) the overlay translucent activity is closed. The strange fact is that other views placed on the main activity (for example, text views showing target coordinates) are correctly updated while behind the translucent activity, also if they are placed on top of the maps.
Is there someone who knows why is this happening, and if there is a way to force map redrawing while host activity is not in the foreground?
I'm trying to make just one activity of my app overflowing behind the software keys, like this
What I already did was to put in my theme definition the following statements
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
and then enabled it on the listView I wanted to overlap
android:fitsSystemWindows="true"
android:clipToPadding="false"
What happened was that my app did overlap on status bar and button bar, but this on EVERY activity and not just on the one I put the two rows above.
Also, it messed up my activity margins: the first row of my application drawer is hidden, and the top of my main fragment as well.
I thought fitsSystemWindows was meant to solve this kind of issues, so I added it to my theme
<item name="android:fitsSystemWindows">true</item>
but nothing changed.
So the question is apparently simple: how can I get the translucent bottom bar, with one of my activities flowing behind it, without messing up the top part of my app and without (if possible) having the same effect on all other activities?
Thank you in advance to each of you fellow helpers.
As Eluvatar stated if I need to have this effect on just one activity the best thing to do is to define a custom theme and assign it just to this activity. That's what I did, I defined an empty style in styles.xml and overrided it in values-v19/styles.xml putting just
<!--<item name="android:windowTranslucentStatus">true</item>-->
<item name="android:windowTranslucentNavigation">true</item>
Then I assigned - in AndroidManifest.xml, the proper style to the activity by using
android:theme="#style/Theme.Style.I.Created.For.This.Activity"
Disabling the first row allowed the activity to just overlap the navigation bar without popping out on the status bar. Margins seem ok as well.
I hope this is going to help somebody else someday.