Default values for Honeycomb - android

Is there a list of default values for Honeycomb text sizes so I can use them in my application for consistency with other built in applications? I tried to apply Holo theme but this has no affect for text sizes, they are as small as on the phone.

There is no "Holo theme" for phones today, as Honeycomb is only for tablets.
You are welcome to examine the Honeycomb styles resources in your SDK to see what various text sizes are listed as. I see many listed in res/values/styles.xml (e.g., dialog title bars are 18sp). You might start with the Theme.Holo definition in res/values/themes.xml, find the item you want, then look up the value in res/values/styles.xml.

Related

Description of Material Components themes?

I am currently getting started with Material components themes. The Getting Started guide mentions these themes:
Theme.MaterialComponents
Theme.MaterialComponents.NoActionBar
Theme.MaterialComponents.Light
Theme.MaterialComponents.Light.NoActionBar
Theme.MaterialComponents.Light.DarkActionBar
Theme.MaterialComponents.DayNight
Theme.MaterialComponents.DayNight.NoActionBar
Theme.MaterialComponents.DayNight.DarkActionBar
There is no description for them though. Where can I find more details about those themes or could anyone be so kind to explain them in an answer? Just for example:
What means [..].NoActionBar? If I don't want an action bar, I don't include it in my layout file, so I really don't get this.
When would I use only Theme.MaterialComponents? Or would I always use Theme.MaterialComponents.Light or Theme.MaterialComponents.DayNight?
How do these themes look like? I couldn't find any preview and don't want to try them all out by myself - could take some time with all the widgets available on Android.
What do these themes define? Only colors? Text style? Font family?
I'm certain that I won't manage to answer all of your questions exhaustively but I'll share some thoughts, maybe it will take you one or two steps further:
What means [..].NoActionBar?
You should use a theme ending with ".NoActionBar" if you don't want the runtime to add an ActionBar to the Activity, possibly because you use a Toolbar. If you choose for example Theme.MaterialComponents.Light and use a Toolbar as well, you will notice that now your app will be renderd with two ActionBars
Please note that if some theme is called "MyTheme" then a theme which is prefixed by "MyTheme." will inherit everything from "MyTheme". So Theme.MaterialComponents.Light.NoActionBar is almost the same as Theme.MaterialComponents.Light except for the ActionBar.
So if you really don't want any ActionBar you should choose the .NoActionBar version and not include a surrogate (Toolbar) in your layout files.
What do these themes define? Only colors? Text style? Font family?
They do that, but they define also sizes, margins and behavior. In addition to that, some of them have special style combos for certain widgets (like style="#style/Widget.MaterialComponents.TextInputLayout.FilledBox" for TextInputLayout)
For a deep dive into what properties can be influenced by a theme, you can take a look at the source of themes_material.xml
When would I use only Theme.MaterialComponents? Or would I always use Theme.MaterialComponents.Light or Theme.MaterialComponents.DayNight?
Since Theme.MaterialComponents is the parent theme of Theme.MaterialComponents.Light, they have much in common. The main difference is that the first assumes that your app will have a dark background (so the text should be white) whereas the second will have black text and assumes your app's background will be light.
Generally, one will try to use a certain theme as a template which then can be/ has to be customized - for example with a special accent color.
How do these themes look like?
You can get a general idea by switching from one to the other in a small sample app of your own.
It's true that there is not one single source of information (aka the android theming bible). You have already found material.io, but maybe the Styles and Themes section from developer.android.com or this blog post on DayNight — Adding a dark theme to your app will shed some more light.

Why does ?android:textColorPrimary get different values with different API versions?

I have an app widget with a white background. Some of the text that displays uses ?android:textColorPrimary, some uses ?android:textColorSecondary, and some use colours I've defined.
For some reason though, when I run my app on pre Nougat (24 or lower), the colours are white such that the text is invisible on the white background, but anything 24 and higher shows as black or grey. The colours I've defined are always ok.
What's also interesting is that the code in the app widget is almost identical to the actual app (both displaying a list of items) and the app version (even on these older API's) uses dark colours but the widget for some reason selects white colours for the text.
If I trace through the XML code in the styles I get to this:
<!-- The most prominent text color. -->
<attr name="textColorPrimary" format="reference|color" />
What does this mean? How does it know what the most prominent text colour is? Why is it different in the widget vs the app, and why only on older API versions?
Is there anything I can do to fix this so that it's consistent? I'm using the same theme. Why would this happen?
Note: as far as just setting a specific colour, this is not what I'm asking. Sure I could just set the text to black or something but I want to use these styles so that in the future the colour can change as necessary, especially since I'm using the day/night theme. Maybe it's related to that? Ok I tried a normal theme but the problem persists (text is invisible on the widget - only the widget - on older than API 24).
Please let me know if anything is unclear and I'll update the question. Thanks.
What does this (textColorPrimary) mean?
This means, that the value specified in the current theme's android:textColorPrimary would be applied. So, if you have declared a TextView in xml and have applied android:textColor="?android:textColorPrimary" to it, then this attribute would be fetched from the theme of the current context with which this layout is being inflated.
How does it know what the most prominent text colour is?
It is fetching that value from the theme that you have applied to your activity or from the context with which the view is being inflated (see ContextThemeWrapper and android:theme). It may differ from platform version to platform version. Depending on the theme you are using, it may differ, see themes.xml.
You can override that attribute in your theme:
<style name="AppTheme" parent="...">
...
<item name="android:textColorPrimary">#color/someColor</item>
</style>
Now, you have successfully overridden android:textColorPrimary attribute, so hereafter any view that is being inflated with a context of this theme would see this overridden value when referring to ?android:textColorPrimary.
Why is it different in the widget vs the app, and why only on older API versions?
Your widget may have been inflated with a particular theme, while app has a different theme. Had they the same theme - those attributes would be same.
Well, ?android:textColorPrimary and ?android:textColorSecondary are attributes and they are resolved by system. It's ok for them to be different on different platforms because you refer to Android attributes.
If you want to define them by yourself you need to create yourown theme and put the values there.

What is the portable way to ensure certain attribute (android:attr/textAppearanceMedium for example) works across different version of Android

Currently, I'm using theme Theme.Sherlock.Light.DarkActionBar.
I'm applying ?android:attr/textAppearanceMedium and ?android:attr/textAppearanceSmall attributes, for the TextView used in ListView
<TextView
...
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
...
android:textAppearance="?android:attr/textAppearanceSmall" />
However, for Jelly Bean and Gingerbread, I get 2 very different effects.
Jelly Bean (Looks great!)
Gingerbread (Ergh...)
Is there any portable way I can tell, when using textAppearanceMedium and textAppearanceSmall attributes on a light background, the color should be dark. Currently, Gingerbread is using light background for its list view. Hence, the correct font color should be dark, so that text is visible.
I understand that you want to support the native look of the respective Android version and want to avoid overwriting default colors.
A "vanilla" Gingerbread version might look like the one in your screenshot, but I have also seen GUI adaptations of device manufacturers (such as Samsung TouchWiz or HTC Sense) or Custom ROMs overwriting these color values. Not only the default background colors, also text colors.
In consequence, you cannot be sure that all pre-Honeycomb versions show bright text on a white background in dropdowns, so you'd have to check the text color as well and adapt it accordingly. Checking background or foreground resources/colors of a view can be very cumbersome, but here are two approaches: https://stackoverflow.com/a/8089242/1140682 and https://stackoverflow.com/a/8848494/1140682
However, I highly suggest that you apply custom, "fixed" colors to your text and background. Since the ActionBar has only been introduced with Honeycomb, there are no ActionBar guidelines/styles for previous versions that you could violate anyway.
A good start for this is the ActionBar Style Generator that also supports Theme.Sherlock.Light.DarkActionBar. It generates all the drawables and style files for you so that your ActionBar and menus look consistent across multiple Android versions and modifications.

Needing a example of how to style an EditText control in the Holo theme to be more like pre Holo

I am trying to more or less copy a PSD that has older controls in it with also using the ActionBar in ICS they like the old style that has the actual box instead of the underline. how would i be able to keep the holo theme and revert a control to the old styles?
Just wanted to show you how i made this happen as quick fix..
http://www.androidworks.com/changing-the-android-edittext-ui-widget
This covers the bases on how to style in depth .. and basically i built my own 9.png files..

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.

Categories

Resources