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.
Related
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
I am developing an application in android. I have an Activity where I have a couple of buttons. Among them when I click on one button, I want to get dropdown like iPhone default picker.
To achieve that, I am using Android wheel concept. I have implemented like this, when I click on the button, it is calling another activity where my required custom layout is shown. Problem is custom layout should come from bottom of the screen in the same activity where the button I am clicking exists.
I have attached a screenshot. I want to achieve as shown in the screenshot (missing).
Please help me providing the required solution. Pardon me if there any mistakes in my question. This is the first time to ask a question.
Since the lack of a screenshot that helps to understand your issue, this is more some kind of guess: Are you known to the concept of Spinners in Android? They provide a dropdown mechanism and are easily implemented.
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.
I'm unclear about when to use PopupWindow vs Dialog. Any insight would be much appreciated. Thanks.
They both use the addView() method along with various windowManager methods. The two are similar in that regard.
Dialogs seem to come with more built-in features for interaction, such as handlers and buttons already included in the base class, while PopupWindows come with more built-in methods for positioning them about the screen.
I think that each of them can do exactly the same as the other, but choosing between the two will be a matter of convenience to the programmer with regards to how you want to use the Object. I'm not a phD in computer science, but I do not think there is a significant difference in processing time between the two based on what I saw in their respective class definitions.
My advice: If you want to have greater control over where your View appears on the display, use a PopupWindow. If you want to add more control and feedback between your View then use a Dialog. If you, like me, want master control over everything, I would suggest a PopupWindow since it has fewer user-evident default methods to override.
I think, that you should use Dialog for simple user interaction (YES,NO).
I usually use Dialog for simple user interaction and WindowPopup for a little bit more complex view.
One example of WindowPopup is AutoCompleteTextView.
Hope it helps.
I think Dialog should use when you need to take action before proceed to continue next. It never cover the screen and always adjust center aligned as modal event.
On other side, PopupWindow has flexibility to adjust information anywhere in the screen as position wise like sticky footer, sticky header, on left, right, center etc. as per location set.
For Showing Information it's good option as there is facility to animate also.
In short, For Showing Information with minimal action go with PopupWindow and for controlled action to proceed next go with Dialog.
I am trying to create a small pop-up in my Android application to let the user choose from one of many items, ala a ListView. I am hoping to make it show up as a translucent box that overlays on the screen, as opposed to completely occupying it like Activities usually do.
One technique for doing this that I've heard is possible is to launch an Activity in an AlertDialog box. This would be perfect - it's the ideal size and has a lot of the mechanical properties I'm looking for, but I'm totally unable to find any more specifics of this technique.
Is this possible? And if not, what is the preferred way of accomplishing something like this?
This should answer your question: http://developer.android.com/guide/topics/ui/themes.html
Quote: For example, you can use the Dialog theme to make your Activity appear like a dialog box. In the manifest, reference an Android theme like so:
<activity android:theme="#android:style/Theme.Dialog">
Maybe you could just display AlertDialog http://developer.android.com/guide/topics/ui/dialogs.html