I want to use the default Alert dialog with a message an 2 buttons.
However, I want to style it differently. So the buttons text color and size, the title text color, size and background.
Do I need to create a custom dialog or is there a way I can change the default one without having to create a custom dialog?
Thank you
The easiest way to do this is to create a new layout xml file, for example dialog_layout.xml. Design your dialog just like you design any activity. Then, before you create the dialog with the builder, and after builder.create(getActivity()), callbuilder.setView(R.layout.dialog_layout) and it should look exactly the way you want it.
Here is a similar question that you can read through
EDIT: small correction
Related
I need to edit default AlertDialog theme so that it will look like part of the design of my app. I don't want to create a whole new theme for it. I will just play with its own properties and make small changes. But the problem is I can't manage to reach the source code and I don't know what kind of attributes it has.
What I need to do is basically to give background a little transparency and roundness.
Does anyone know where can I get the AlertDialog style code? And which attributes do I need to edit for transparency and roundness of background?
Thanks.
Here's the style code for AlertDialog: https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/styles.xml
I don't know how to change it the way you want though.
How to make square (or round) floating activty? There's a variant with system alert window, but I don't think it's a good idea. Is there any ways to do this customizing dialog theme?
You should use a dialog fragment. It is highly customizable.
Use DialogActivity & make your layout as per your round or square.
ref : URL
Android custom dialog example
Custom Dialog
Set customized style would change the default corner of activity.
I need to create a custom button control that will inherit from the same Android style as all other buttons in my application. However, I want to be able to add several lines of text where some characters of the text will be in different colors. Is there anyway to achieve this, I can't seem to see a way?
Currently I have created a view that looks like a button by drawing the background, this is ok but I want the background etc to change with the application style.
You should make your button descend from the generic theme for Widget.Button. This way you can ensure that all the default settings will come through for you.
I've spent all day trying to find this to no avail! I want a summary for my users after using my app, and a simple dialog is the obvious solution. However, I am unable to customise the theme to change the background and buttons. Every tutorial and explanation I've found on this matter is using API 11 techniques and I'm targeting API 8.
Is there a way to set the dialog theme for API 8 so I can change the background drawable, font, icons, etc? I've found various techniques for changing font, icon, adding a drawable, etc. (eg. http://www.helloandroid.com/tutorials/how-display-custom-dialog-your-android-application), but nothing that changes the background graphic or colours.
//set up dialog
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.dialog_layout);
Just specify a custom layout file for you dialog and specify there all the attributes you need including background drawable etc.
I have read lots of articles, here and elsewhere about customizing AlertDialogs, and those created by AlertDialog.Builder.
The approach that I'm using at the moment is injecting my AlertDialog.Builder with a ContextThemeWrapper. This ContextThemeWrapper is configured to read from a custom style that inherits from Theme.Dialog.
My customization requirements are quite straightforward:
Change the title bar background colour from the default navy/black version
Change the font type and size of both title and buttons
I've had a look in the default themes.xml and styles.xml but I don't see where to configure number 1 in particular...can someone let me know how this is done?
Also, some of the solutions I've seen involve inflating a layout and then setting this using AlertDialog.Builder.setView()...if I was to customize using this way then how do I design the views for positive and negative buttons?
Thanks
Sorry, alert dialogs are not really intended to be themed like that. They are basically the most concrete thing you can do -- a canned appearance for standard common situations.
If you want to have a dialog with a customized appearance, you should just start with the Dialog class.