I'm working on my small app and I have terrible problem with dialogs. Partially my question will be technical, partially general.
For example I have the following scenario: 1) user select file type 2) user select file 3) user select some additional options - list of about 5/6 options.
I'm wondering if to do this as some kind of three steps wizard (for each step separate dialog) either as one activity with three buttons/elements for selecting the appropriate elements. How do you think? I would like to have my app giving some kind of light appearance to users, thus I would prefer not to have heavy things. have you seen any good examples of more complicated dialogs/activities? Any official guide for more complicated dialogs?
Moreover some technical questions:
1) Is that possible to have activity (full screen) looking as dialog (style)? If yes, how?
2) As for now I use DialogFragment. However android by default sets its dimensions in the way that there is no need to resize them when changing screen orientation (screen smaller dimension is the base for setting dialog size). In consequence when having screen in vertical orientation huge part of screen is not used by dialog. How to change that to have dialog occuping almost the whole screen, but also resizing correctly when changing screen orientation and if possible with still keeping setRetainInstance(true) (less problems with dialogs when changing orientation)?
use the following line of code in your activity below setContentView(R.layout.activity_main);
setTheme(android.R.style.Theme_Dialog);
refer following link,
Android: how to create a transparent dialog-themed activity
Related
I am trying to know if it is ok to manage the "navigation" of my app with DialogFragments all the time, putting them in fullscreen as if they were Activities.
Thank you very much
You can do this. You can also do the opposite (using activities as dialogs, which is just weird).
The only real reason to do so is to reuse a fragment both as a dialog and as a full screen view, perhaps for different screen sizes, etc.
You might have a UI design in which you want a piece of the UI to appear as a dialog in some situations, but as a full screen or embedded fragment in others (perhaps depending on whether the device is a large screen or small screen). The DialogFragment class offers you this flexibility because it can still behave as an embeddable Fragment.
http://developer.android.com/guide/topics/ui/dialogs.html#FullscreenDialog
Doing this in general for no real reason would be an odd practice
Is it possible to create an activity in Android that doesn't take up the entire screen? I would like to create one that is only 1 pixel x 1 pixel wide and launch it.
No it is not. An Activity is designed to be the current active screen.
You can 'fool' people with the view that goes with the Activity, such as making it (partly) transparent but your Activity will still be the one receiving touches.
Create activity with dialog Theme by using this
android:theme="#android:style/Theme.Dialog"
Activities are often presented to the user as full-screen windows,
They can also be used in other ways: as floating windows (via a theme with windowIsFloating set)
or
embedded inside of another activity (using ActivityGroup).
If you want to create with given pixel you can not do it.. Instead you can go for Fragments, DialogInterface in Android which can be created with size specified in layout xmls
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
Ive been doing some reading, and got a little confused. In Android development, is there a difference between a Screen and an Activity? What are they? I was reading about an Activity having multiple screens.
An activity is a piece of your application which should handle a single specific task (example, receive input from the user or display images or whatever you want).
The part you are referring, "supporting multiple screens" can be explained as a best practice you should follow when developing your application: this is simply the designing of proper layouts based on different possible screen sizes and densities. There is nothing such a "Screen" class in android.
So the relationship between an Activity and the moltitude of screen sizes out there is mapped by the layout XMLs defined in the proper layout folders in your application. The android OS will choose and handle the layout for your activity based on the hardware screen available and the closest-to-best layout you defined.
Think of an activity as a "window" on a desktop OS (like Windows7 or MacOSX or Ubuntu) that allows you to see only one window at a single time. If you have 10 different activities in your app the user may see up to 10 different windows. The android OS will pick the most compatible layout you defined based on the real screen display the user has and places the GUI component accordingly.
An Android activity is the screen you see on your device ie a welcome screen with buttons or whatever. The activity can call other activities which then will show on your device screen. An activity is where you define all your logic for what happens on your device (Of course you can define the layout of your activity in a layout xml file).
An Activity is similar to a form(If you are aware of web development form).
Screen is just displaying activity so there is no object like screen.
For layout control of an Activity you can use main.xml ( Also it can be done using code in your activity extended class.)
I would like to ask you guys/girls, if somebody have any idea how i can achieve a two activity transition in honeycomb, where the the not used activity will be visible a quarter of the original size and the other activity will be place to the center. Also i need to mention i used activities smaller then the screen resolution with dialog theme to get them to the center.
I looked into the ViewAnimator, ViewSwitcher, ViewFlipper, but i`m not sure if can do that. (Sure need to override this classes)
Somebody have any idea ?
You cannot have two activities "active" at the same time so showing any proportion of one activity and another and interacting with both is not possible, if you don't care about interacting with both simultaneously you might look at the SlidingDrawer class, a lot of people have customized that.
It is possible to kind of fake what you are asking by using two layouts and changing their proportions/position at runtime, for instance you could have a layout that takes up the entire screen, then on some event it could be re-positioned/sized and a hidden layout shown.
That is if I am understanding your question correctly.
Update
Also have you looked at fragments?