I realize the question is kind of weird, but I want to stop using deprecated options menu and switch to action bar. Unfortunately, to do that I must use Holo theme, which comes with a different AlertDialog design that was before.
This new design breaks my UI appearance. Is it possible to create an old-styled dialog in a Holo-styled activity?
Arelated question: is there any thing other than AlertDialog that is a pop-up window capable of showing my own layout, and that doesn't have borders and other theme-defined stuff around my custom layout?
Depending on the minSDKVersion set in your AndroidManifest file you can choose a theme for your dialog. You can set them to Holo / Device Default but to do that your minSdk value should be 10+ even I think that to use DeviceDefault it should be JellyBean.
If you want to create your own layout and use it without any borders and etc which will break your design you should use Dialog instead of AlertDialog and customize it. You can do something like this :
final Dialog alert = new Dialog(FingerPaintActivity.this, android.R.style.Theme_Light_Panel);
alert.requestWindowFeature(Window.FEATURE_NO_TITLE); // no title
alert.getWindow().getAttributes().windowAnimations = R.style.PauseDialogAnimation; // this is used for custom animation when dialog is showing and hiding
alert.setContentView(getLayoutInflater().inflate(R.layout.stamps, null)); // here is your custom layout
alert.getWindow().setLayout(width-50, (height-100)); // set height / width
and when you want to trigger an onlclick in your button for example which is placed in R.layout.stamps as in the example you should do like this :
Button dog = (Button) alert.findViewById(R.id.dog_stamp);
You can create a custom AlertDialog.
For example : http://www.mkyong.com/android/android-custom-dialog-example/
Related
I've got an AlertDialog and I would like to change the height of the underlaying background, not the dialog itself. Haven't been able to find any source online showing if this is possible or which attributes in the alert dialog theme to manipulate. The only attribute that seems to change anything with the underlaying background is dimAmount. Here is what I have:
Here's what I would like to have:
As you can see the action bar and bottom navigation buttons are no longer being covered by the AlertDialog underlay.
In Google's Material Design document, it shows a full-screen dialog with a header that contains a X close button and a SAVE button. Is there a support library way of getting this dialog treatment easily?
Material Design Components Dialogs
Use a support toolbar (android.support.v7.widget.Toolbar). Put it at the top of your layout.
It looks like an actionbar but you can just give the views inside it onClick handlers to handle save and close.
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....
I would like to modify the background of the title bar of the dropdown dialog associated to a spinner.
If this is not possible I would like to know what resource is used to draw this background android.R.drawable.* ?
This is an effort of uniformity for my various pop ups in my application.
You can change everything using styles and themes.
Take a look at this example for buttons:
http://blog.androgames.net/40/custom-button-style-and-theme/