I want to have my Toast's entrance and exit animations customized. Specifically, I want to make it appear instantly (no fade-in) and disappear like normal (fade-out).
Is there a way I can use animations with a toast?
Toasts are displayed using a system template that can't be changed so short answer is no you cant change the toast animation.
however you can make your own view that resembles a toast and animate it however you want.
It is not possible to do this with the stock Android Toast class. The Toast class is limited to four system animations and will not accept animations from your project.
See: Android add custom animation to Toast
Related
In Android I can display short messages to the user either using Toasts or Snackbars.
Is there a particular standard as to which ones I should be using? All Toasts? All Snackbars? Toasts during DialogFragments and Snackbars otherwise? Is there a way to force a Snackbar to display on "top" of the rest of the screen (in the event that I don't want to pass a specific view to it)?
If you want to confirm to the user that something just happened, that something went ok etc. a Toast is the way to go I would say.
But if the user did something like for example removed an item from a list, you would want to give the user an option to Undo. It could probably be done with an alert dialog but that's also annoying for the user. To be forced to change focus and act to an alert dialog asking if it's really what the user wants to do, for example "Do you really want to delete that? No Yes".
With a SnackBar you can inform the user that the item was deleted but also provide an Undo-action. Which should put back the item into the list on click.
Look at this short video, she explains the usage of those better :)
https://www.youtube.com/watch?v=puhfMX8jb9c&list=PLWz5rJ2EKKc-lJo_RGGXL2Psr8vVCTWjM&index=5
Snackbar it's material feature, Toast - holo style.
If your application has material design, more better use Snackbar as material item(like physical peace of paper) instead semitransparent/shadowed Toast.
In comparison to real world:
How often do you see "text in air"? Newer)) But may be when you under some drugs it possible) Ghost is unreal) Due to material world, texts on papers, boards, another physical places is normal behavior.
In case of upper snack, discover this
I need to make an android app that has a very dynamic ui.
For example imagine we have an activity with only one button inside that in center. Then when someone clicks the button. The button converts to edittext. When user enters some text, the editText converts to textview. And then under the textview, two new buttons automatically Appear. This proccess will go on untill user create a binary-tree like structure. I want this kind of UIs.
I Hope you Undrestand My Problem.
My question is, how can i achieve this kind of UIs?
Can you give any suggestion?
It depends on what the requirements are, are we talking about simple animations like fading out and fading in, maybe some pulsation and then edit text appearance. It depends because it might be enough to use existing tools like using the ObjectAnimator or even xml or you will have to do some fancy stuff as in writing animation code that meets your particular requirements. Apart from that a factor is what versions of Android are you trying to support JellyBean and above or Lollipop and above.
Currently, I am using Libgdx for making app with lots of animation. I am trying to use android Dialog for showing paragraph with html tags through Interface. While, I can change dim color of background UI back to normal with following code.
paragraphDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
Is there anything I can do to make background UI work? (Button click, textview focus etc)
And, I have tried GlyphLayout of Libgdx for paragraph. It frequently crashes & also doesn't support html tags. I am using dialogs, as it is pretty easy to use xml layout easily with dialogs. If there are any other options, Please suggest.
Thanks,
your dialog is blocking the entire screen, doesn't matter if the edges/background are somewhat transparent or not 100% alpha, it is still the view that is currently on top. therefor, you can't click on it directly.
i think the best way to achieve your goal is with a fragment. not a dialog.
I am using a hack to display an overlay over a picture in Google TV using a constant toast message.
I would like to know if there is a way to further modify the toast to remove the fade in and fade out effect. Ideally I would like the overlay to appear instantly.
Any help or direction would be greatly appreciated.
For this , i suggest we can use a layout(FrameLayout).
and by using a new layout above your current layout and adding view that looks similar to TOAST to the top layer
After that do one thing by making object of View as v
eg:-
View v;
v.setVisiblity(GONE);
v.setVisibility(VISIBLE);
This will make your view appear or hide.
You can use a FrameLayout and create a new Layout layer above your current layout and add a view that looks like toast to the top layer.
Then you can use: View.setVisiblity(GONE); and View.setVisibility(VISIBLE);
to make your view appear and hide instantly.
View.setVisibility Documentation
FrameLayout example
I like a fade-in effect, but I was in need to cancel a toast message immediately without fade-out effect, since the toast message remained shown for a short moment even when the Activity was already exited.
I came to this solution to close (or actually hide) my toast message t immediately:
((TextView)t.getView().findViewById(android.R.id.message)).setTextColor(Color.TRANSPARENT);
t.setText("");
t.getView().setBackgroundColor(Color.TRANSPARENT);
t.cancel();
I assume to set colors transparent is the only way to hide the fade effect with standard Toast layout.
After seeing the last screenshots of new foursquare application and their balloon like cartoon instructions, I'd like to create some of these in my application.
I found a similar question for iPhone
Small popup for instructions... How?
Here is another screenshot of foursquare app:
I'd like to know how I could achieve that with Android.
Thanks in advance for any help.
UPDATE: This is what I could get so far but adding some buttons with a custom drawn background and layering them with a FrameLayout:
But I still couldn't get the triangle effect. Maybe there is something I can do with my custom background shape?
UPDATE2
After checking your suggestions, I decided to go with Aaron C idea and added an image with an arrow on it. This is my current result:
Thank you Snailer, QuickAction API project seems very much promissing. I'll check it out when implementing more features in my app.
Now, I just need to get the right color or maybe I could just let it this way. It seems nice too.
And, so, to summarize what I did:
Got my initial xml layout inside a FrameView.
As I'm using a frameview, everything I put in here will be piled one over the other. That's how I could add things to the layout.
In that framelayout, I put 2 relativelayouts whith an image with the triangle and a button to create the two upper popups. In the bottom I put a button only.
That's it. I hope it helps somebody.
Thank you very much again for all your help!
That sounds like a neat thing to implement. There might be a built-in Android variation on AlertDialog that achieves this, but if not here is how I would go about implementing it:
Create a new Activity whose background is black with a very high (low?) alpha color value. This will allow you to see through it to the previous Activity in the stack. Then, add your alert at whatever coordinates you like using a relative layout with padding values.
You might also want to add a touch listener that exits the Activity if the user touches the balloon (or maybe anywhere in the screen).
If you want to be fancy with coordinate placement of the balloon, you can pass this information into the new Activity using the Activity's launch Intent with the putExtra() methods.
It's probably achieved through skinning a toast.
The developer documentation shows a skinned toast in "Creating a custom toast view" at http://developer.android.com/guide/topics/ui/notifiers/toasts.html
You may want to look at the QuickAction API. It acheives this by using PopupWindow, skinned, positioned, and animated.