android game pause screen , dialog or activity dialog? - android

I am a little confused about the best way to show pause screen on my android game. will it be better to be a pauseMenuActivity or is it enough with just pauseDialog? this pause dialog will just show score, money, back button, option button , and quit button. if it is better to show dialog, I don't know how to show those buttons and background image.. anyone can help me? thank you

I would recommend going for a Dialog (or some other custom overlay). From my experience, inter-Activities transitions aren't always very quick and they can feel kind of sluggish in the context of a game. In my opinion, when I am on a pause screen and want to start playing again, it should be instantaneous.
Plus, an Activity is kind of overkill if you just want to show 4 buttons.
To create a custom dialog containing a custom layout, have a look at the following tutorial and post again if you have specific questions/problems :
http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog

An Activity in general is better than a dialog, because u can take care of all things like orientation, theme etc. and it provides more flexibility. Though in simple cases u can use a dialog.

Related

Android - Show more information on a popup

I'm developing an app that includes reviews of items and due to my design, I want to only show all the reviews in a popup window like in Google Play Store:
What should I use to create that white panel that appears over the current window and contains the necessary information? This should be simple but I'm a newbie and I can't seem to figure out what this "widget" is. Please help me if you are familiar with this so I can use this cool design pattern. Thanks.
It seems you want to display a layout as a popup in another activity.
If you want to do this using an Activity instead of a Dialog, you can do this by setting the activity's theme to android:theme="#android:style/Theme.Dialog" in the manifest - this will make the activity appear like a dialog (floating on top of whatever was underneath it).
A better way to do it would be using a DialogFragment. You can display information in the form of a popup and it will have its own lifecycle. That will be much better than displaying an activity like a dialog
Ram kiran's answer is a good one and one which I like to give also. But just so you have another option to look at you can consider PopupWindow
As stated in the docs, it is
A popup window that can be used to display an arbitrary view. The popup window is a floating container that appears on top of the current activity.
I've used this and it works out nicely in some situations. It really depends on what your exact needs are as to which will work best for you.

How to make the ambience of a Dialog transparent

I want to use a Dialog for the pause screen of my game. But the dialog always shades the subjacent Activity (the ambience around the dialog). How can I avoid this effect?
Afaik Dialogs in Android have that default behavior and it cannot be changed. For your requirement you should use something like a PopupWindow. This and this are the links to tutorials that can help you get started.

Popup window using Fragment

I want to create a pop-up window (with black transparent background around it) that would appear above the application activity screen (by clicking on a button). This pop-up would contain a video player, a list of videos to be played and some other elements.
This pop-up has to be a fragment since I need to re-use it from other app fragments.
So my question is : what is the best way to achieve that? I personally see 2 options :
1) adding the pop-up as a fragment on the layout and to show + activate it whenever I need. But in that case, how can I put a black transparent background around it that would fill the whole screen?
2) using DialogFragment but it seems that this class is not very well-designed for this kind of stuff.
What do you think?
Thanks in advance.
DialogFragments are the suggested way to launch Dialog views from within a Fragment, so this is the solution I would suggest for you.
You can do pretty much anything you need within the DialogFragment. You will be in full control of the UI using this method.
Here is a SO discussion of the same point, with good info: Android DialogFragment vs Dialog

How was this made?

This screen was captured from Gmail app for android. The popup looks pretty cool with images and all. Any ideas on how this was made?
This is done with a custom dialog, it is actually quite easy to achieve. Just create a layout for a normal Activity and pass it to the Dialog builder.
For more information, check http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog out

Showing a Dialog and still delivering clicks to the background?

I want to show a small Custom Dialog on top of the current user activity, but have clicks to the area outside of my Dialog delivered to the background (which would be the launcher, or another activity). I tried to create a transparent base-activity and have the Dialog shown on top of it, but clicks are registered on the transparent activity and not on whatever is behind it...
I know that a Popup has a setOutsideTouchable-Method, but setting this to true just dismisses the popup, rather than delivering clicks to the background, to my knowledge...
Thanks for your help,
Nick
Based on this clarification comment you posted on another answer...
"I want the Dialog to be shown system-wide, no matter which App the user is using at the moment..."
I don't believe what you want to do is possible and I'm happy about that. :) If you were allowed to popup a little dialog box over anyone else's app and still have the user be able to interact with the current activity... then you could easily trick the user into thinking that the little popup belonged to the current app and not yours which is acting from the background.
Imagine all of the evil you could do with something like that. Prompting for the user to reenter their email password when they are in the Email.app.. and then just storing it for malicious purposes, etc.
It isn't possible.. and SHOULDN'T be possible. If you need to notify the user of something, then you should use the built-in notification system. That's why it is there! :)
You can use a PopupWindow "Dialog like" and show it for the user in top of your activity. The outside events will be delivered to the main Activity.
I can't see the deeper meaning of exploiting the using the given usability patterns of android by doing what you ask for?
It is recommended and meaningful to stick to common patterns so users don't have to adapt in basic apps. That is, unless you are working on a game:)
"I want the Dialog to be shown
system-wide, no matter which App the
user is using at the moment..."
That is what the notification system is for. It allows you to tell something to the user without interrupting him in whatever he was doing.
System wide dialog popup are evil and gladly not implemented in Android.
Use the notification system : http://developer.android.com/reference/android/app/Notification.html
Also if you are ok with only a dialog above YOUR app, then the simplest way to let the UI be still responsive while your dialog is up, is simply to recreate a dialog in a relativelayout view and display this instead of the common modal dialog.
You could switch places so that the popup is actually "behind" the initial screen, but then set the initial screen as transparent.
Edit: This would only be applicable within an application of course.

Categories

Resources