Is it possible to custom dialog theme in Android API 8 - android

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.

Related

TimePickerDialog custom theme

I'm developping an Android app and right now I'm having an issue with a part of my UI: a TimePickerDialog. I'd like the top part of the Dialog to be orange instead of the classic
I know that I could create a custome theme, but my boss want it developp in 4.0 (API 15) so that it covers almost every device.. I don't know how to set a color with using settings covered by API 21 and up..
TimePickerDialog appearance is very different in the API levels you are testing on. The biggest redesign was probably made in Lollipop (API 21), where the default dialog has a totally different (circular) look:
If you are testing on API21+, you are probably seeing this one. The background color AFAIK can be changed by tweaking the android:color* attributes in your theme. I'm not sure which one (could be android:colorAccent, android:colorPrimary...), but it is easy to determine.
However, since you are going to deploy down to API 15, and default time picker there is quite different, I would recommend using an external library to give each user the same look and feel of Lollipop.
The most used is probably this one, and allows you to style the dialog in terms of colors and much more.
API>=21:You can define <item name="colorPrimary">xxxx</item> in your style of theme
API<21:Use libary for example material libary

Adapting AlertDialog to a specific design

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 get the new Android progress view that is in 4.0?

I have just tried implementing a ProgressBar with the following two styles:
?android:attr/progressBarStyleLarge
?android:attr/progressBarStyleSmall
However, they are the old, vanilla progress spinners that Android has always had. See below:
I'm looking for the progress bar that comes with the 4.+ theme. It's the one that has one progress indicator rotating clockwise, and a semi-transparent indicator running counterclockwise at a slower pace. The heads then intersect at 5 points (star formation) across the circle, like the image below.
How do I get this ProgressBar in my app?
You should define a custom theme, then have it inherit from Theme.Holo in API level 11+, and from Theme for all others (or their light variants). To do so, see Select a theme based on platform version.
That way the progressBarStyleLarge attribute will be mapped to the new resource (progress_large_holo) in devices that support it. This will also change all other resources though (such as backgrounds for EditText, &c).

Theme Sherlock Dialog API 10

I've been testing my app on API 10 and a couple of views seem to to be different.
Firstly, the background of all dialog boxes seem to be black when they should be white as on the new APIS:
Secondly, the text for the the tabs are dark grey as opposed to white on the newer APIS:
How do I change the XML themes to keep it consistent?
Thanks in advance.
If you navigate to the abs_attrs.xml file in the ActionBarSherlock library, you'll see that the themes have a bunch of name-value pairs for all kinds of attributes. You need to find the name-value pairs that are used in the dialog. Usually the names are pretty self explanatory and you can see how these attributes are used in the abs_theme.xml file.
All you need to do is override (add them your app's theme) the appropriate attributes. If you haven't themed ABS before, you should read a bit of the documentation on "mirroring" http://actionbarsherlock.com/theming.html.

Android: Simple customization of AlertDialogs

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.

Categories

Resources