I am trying to get a fullscreen dialog on smaller devices and normal dialog on larger devices.
From Android docs: http://developer.android.com/guide/topics/ui/dialogs.html
Showing an activity as a dialog on large screens
Instead of showing a dialog as a fullscreen UI when on small screens,
you can accomplish the same result by showing an Activity as a dialog
when on large screens. Which approach you choose depends on your app
design, but showing an activity as a dialog is often useful when your
app is already designed for small screens and you'd like to improve
the experience on tablets by showing a short-lived activity as a
dialog.
To show an activity as a dialog only when on large screens, apply the
Theme.Holo.DialogWhenLarge theme to the manifest element:
For more information about styling your activities with themes, see
the Styles and Themes guide.
So instead of a real dialog I have an activity. That activity looks great on a phone. Most important part is that the activity has an action bar with a menu button.
When I launch the activity on a larger device the activity does appear as a dialog, however the action bar is removed, along with the menu item that lived in the action bar.
Here is the style I am using:
<style name="dialog_theme" parent="#style/Theme.AppCompat.DialogWhenLarge">
</style>
Dialog's do not support action bars....bummer.
BUT, dialog's do support toolbars. I was able to user a toolbar to get a consistent look and feel across the full screen activity and the activity shown as a dialog.
Related
We are creating a KIOSK app on API 22. We want to have custom status bar. And with two finger swipe from the top, options menu is opened where we can edit sound, wifi etc. just like regular swipe from top on android phones.
One option would be to edit Android source code, but we are wondering if there is something we can do on application level since we need to have some strings and buttons from app in that status bar, besides WiFi signal and battery.
What we have done is we added a fragment on top of the screen which acts as a status bar, and below it is a fragment container for other fragments.
Problem here is we need to have a transparent background of the fragments in fragment container, so when user opens multiple fragments, whole fragment stack is visible in the background.
Only way we could achieve this is by using fullscreen dialog fragments, but then we had to make multiple instances of our "status bar" which overlap and only looks like one view to the user:
This leads to maintaining multiple views instead of just one. Also the problem is since we are using Navigation library, when Fragment 1 changes in the background it also pops all dialog fragments, which throws the user to screen he was not on.
One thing we tried is to set dialog fragments window to be (size of screen - status bar) but then we could not click on status bar, since it is behind our dialog fragment.
We are considering of using activities instead of fragments, since then we can have transparent background and we don't need to use dialog fragments, but to have activates everywhere instead of fragments doesn't sound like a good idea.
Are there some other options?
Background
I have an app that has 2 activities :
splash activity, which is shown in full screen (no action bar, no notification bar)
main activity, which has both an action bar (uses actionBarSherlock) and a notification bar.
The problem
For some reason, when going from the first activity to the second, there is a "jumpy" layout process, which shows the content of the second activity without the action bar and notification bar, and a moment later it shows them both.
This causes the content below to move too, which is very noticeable.
Possible solution
As I've seen, a possible solution would be to hide the action bar and show it a bit later (500ms later), but this seems like a bad solution (making it slower and hiding for no reason), plus I need to get the actionBar items positions for another purpose (for showing a tutorial).
The question
Is it possible to avoid the "jumpiness"? One that doesn't involve such a weird workaround?
I've solved my problem doing the following:
1.- I have to optimize all the screens where the AB was shown. In some cases I used ListViews which weren't correctly implemented and that caused a noticeable load time in the activity.
2.- I have shown the status bar BEFORE starting the new activity. I mean: I've shown the status bar in the fullscreen activity just before starting the non-fullscreen one. With that I achieved that the layout of the second activity (non-fullscreen) was never resized.
With this two little changes now the AB transition is much more smoother.
You can find the complete post with my answer at: Smoother transition from fullscreen activity using ActionBarSherlock
Why don't you use some other animation slide transitions rather than default popping one?
something like this?
overridePendingTransition(android.R.anim.accelerate_interpolator, android.R.anim.slide_out_right);
Here is the Animation lists that you can use
http://developer.android.com/reference/android/R.anim.html
I am Developing an application which consists of custom-title-bar.
1.I have implemented custom title bar in my application,until here every thing is working fine for me.
2.I have removed the custom title bar in splash screen,when i am loading the application in emulator, Before the splash screen,custom-title-bar is loading and then splash screen is displayed.
3.my requirement is i need to display the custom-title-bar before the splash-screen.
What I understand from your problem is, your main(launcher) activity contains custom title bar, it launches splash screen which is not containing title bar. So it is obvious that title bar is gonna hide behind splash screen. If you dont wanna implement custom title bar in splash screen then it is advisable that you make your splash screen background's(image's) top "white and transparent"(with the help of photoshop) so that title bar of main activity is visible behind the splash screen.
In a v3 android application, is it possible for an activity that has a dialog theme (e.g.: Theme.Holo.Dialog) to have an action bar? I tried adjusting the windowIsFloating Attribute, but that caused an exception along the lines of "actionbarimpl not compatible", indicating that the current dialog theme does not support action bars?
It should be possible as several applications on the Samsung Galaxy Tab have dialogs with action bars.
Thanks.
The Dialog Theme wasn't designed to display an ActionBar.
Read this for more information.
When using a Dialog you want the user to choose between different options and make some decisions. I don't know what your Use-Case is but you better change your UI-Design so that you can manage your use-case with another solution. A solution Android was designed for.
If you really want to use a Dialog with a ActionBar, you can create your own by using a
Custom Dialog with a custom layout and build a ActionBar clone-layout.
I'd like to be able to create an Activity that matches a default system Dialog. So in Android 2.2, it'll look like a Dialog for that version, in 2.3 it'll look like a Dialog for 2.3, etc.
The usual answer starts off with set android:theme="#android:style/Theme.Dialog" in the Activity manifest. However, that just gives you a floating box with unstyled text. What's missing is a title over a title bar, the dialog text, and the dialog buttons---all styled to match a system Dialog. What system styles should I use?
For example, I found TextAppearance_DialogWindowTitle in R.style. This gives you the text size for the title. Still missing is styling the title background, the buttons, etc.. Any ideas? Android style and theme documentation is sorely lacking.
I would just use the dialog builder except that I need to use a custom icon, so I would be back to square one styling a custom dialog....