TimePickerDialog custom theme - android

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

Related

?attr/colorPrimary support version?

I am in a fairly serious predicament. I have built my entire app using ?attr/colorPrimary to pick the color for background shapes, as I have devised a way to dynamically change the theme and color. This works perfectly on 5.0, but on all 4.x devices, ?attr/colorPrimary crashes the app. Why does Android studio not alert developers to this incompatibility?
Is there a support version of ?attr/colorPrimary?
colorPrimary is already part of AppCompat as of version 21 and works back to API 7. Your problem is instead with your theming code.
I believe it was added after Android Lollipop - API 21.
At least this link shows that it was added between API 20 and 21:
https://developer.android.com/sdk/api_diff/21/changes/android.R.attr.html
attr/colorPrimary just point to colorPrimary defined in current theme.
I'm not sure how you implemented your theme.. But you can create your own attr... This option is good only if you support several themes.
If you have a single theme, I believe you can replace it by a color.
API 21:
Material design style
Notifications are drawn with dark text atop white (or very light)
backgrounds to match the new material design widgets. Make sure that
all your notifications look right with the new color scheme. If your
notifications look wrong, fix them:
Use setColor() to set an accent color in a circle behind your icon
image. Update or remove assets that involve color. The system ignores
all non-alpha channels in action icons and in the main notification
icon. You should assume that these icons will be alpha-only. The
system draws notification icons in white and action icons in dark
gray.
The problem is a glitch in Android code. See this, it is not the exact same but the reason is.
In case anyone out there has this problem, I want to explain my workaround.
Remove all instances of "?attr/color(Primary, Dark, or Accent)" and attempt to mimic the effect in each individual element in each individual activity. This is not a full work around, but for me it works. Google really needs to resolve this issue. If you know a better work around, please let me know and I will accept it as the better answer as long as it works.

numberpicker widget and holoeverywhere missing theme

I'm trying to get Simons Number Picker to work together with Holoeverywhere. however holoeverwhere requires me to set android:theme="#style/Holo.Theme" whereas the number picker requires android:theme="#style/SampleTheme.Light". I'm not very familiar with styles and themes yet, what are my options? Right now the number picker displays incorrectly:
PS. I need backwards comp. till 2.2 and would prefer keeping the holo theme
There is a built in NumberPicker in HoloEverywhere.
You can test it with the demo application.
org.holoeverywhere.widget.NumberPicker
Here is a link to the source code:
https://github.com/ChristopheVersieux/HoloEverywhere/blob/master/library/src/org/holoeverywhere/widget/NumberPicker.java
MOVED TO: https://github.com/Prototik/HoloEverywhere/blob/master/library/src/org/holoeverywhere/widget/NumberPicker.java
Maybe there is a way to use Simons widget on a dark theme, should be possible.

Background gradient not showing on Holo theme

In styles.xml inside of values/, values-v11/, and values-v14/, ive set the AppBaseTheme to android:Theme.Holo.
Now it seems to work well, except it is not showing the nice background gradient when I run it on a 4.2 AVD with API level 17.
I saw something along the lines of hardware acceleration. Could this be why it isn't showing the background gradient that the Holo theme should use? Is it something in the settings within the AVD? Or am I missing something else?
How do I get the Holo background gradient to show in my app when I run it on the AVD? I know this is purely cosmetic, but I think it looks nicer and I want my app to utilize it.

How to handle the fact that Dialog background in Theme.Light are black on pre-ICS sdk and white on ICS

In my application, I use some dialogs to display information.
The theme of my application is Theme.Light since 2 years, and these dialogs have always been black since the beginning.
Now with ICS, it seems that Google just changed his mind and turned these dialogs into white:
See the screenshot of my Moto Xoom and my Galaxy Nexus:
What is the best practice to handle that true fragmentation?
I have been thinking about creating different layout: layout-v14 but I will soon become crazy, if I have to create layout-v15,v-16, etc for the future?
Or is there a way to tell "lower than v14" and "higher than v14"?
layout-v14 apply to v14 and higher, so if any different style will appear in future you able to add layout-vXX to support this. And all versions between v14 and vXX will apply v14 layout.

How do I use common UI styles in Android?

I am writing my little Android app. I pop up a dialog control which is a nice, non-fullscreen, rounded-corners dialog by setting android:theme="#android:style/Theme.Dialog" on the activity in my manifest. That all works just as I expected. However it is just a drab, grey-titled dialog as in this screenshot:
I've noticed however that a LOT of applications, when they pop up dialogs have a nice, blue-themed title as in this screen shot.
I would assume this theme is some common theme, as it shows up in a LOT of different apps. I would assume it is something built in to the OS. (My phone is a Captivate with the official Froyo release). Of course it COULD be something that every developer simply re-coded on their own, but I doubt that.
Assuming that this is a common theme, how do I utilize it in my app? What changes do I need to make to my activity to have it use that theme?
Thanks in advance!
You can set your activity to use a default theme like Theme.Black. There are default themes and they are in R.style - although i'm not sure which are available to which platforms(i.e. i think the holo themes are for 3.0 and up...
http://developer.android.com/reference/android/R.style.html
see here http://developer.android.com/guide/topics/ui/themes.html for defining your own custom themes and scroll all the way down for using the "platform styles" and themes.
Rather messy (there doesn't seem to be a good reference for this), but the platform styles are defined in \platforms\android-\data\res\values\styles.xml and \platforms\android-\data\res\values\themes.xml. You can dig through those and figure out the theme/style IDs that are available at compile time.
Other than that its really just trial and error.
To make a dialog you need to extend the dialog class. And to have a nice title bar you can use:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
and have your own custom title.
to have a title use:
setTitle("MyTitle");
You can also assign your custom view for the title.

Categories

Resources