**I'm probably going to get flamed for this, but I have my reasons.
I'm making app has an option to switch between 3 themes (Holo Dark, Holo Light, and Holo Light with Dark ActionBar). Because of certain reasons, I used >>this<< hack to make ActionOverflow work with devices with hard menu keys using ActionBarSherlock 4.2. The problem is that whenever I have the theme set to Holo Dark or Holo Light, the height of the menu items is a rather large (about 48dp), but whenever I have it set to Holo Light with Dark Actionbar, the height of the menu items is normal (whatever normal is).
Anyone have any ideas what's making the menuitems act strange?
I've tried checking in Styles, but I'm not sure where the problem is originating from.
If you need more info, just ask :D
Got it!
I gave up soon after I posted this question, but I came back to it, played around with the ABS library, and found out the answer!
What I did was add:
<item name="dropdownListPreferredItemHeight">48dp</item>
to my styles.xml within:
<style name="ThemeDark" parent="Holo.Theme"></style>
I did this to both Dark and Light themes and it's working just fine! :D
Related
I'd like my Android app to have toolbars the same color as the primary surface (and the status bar -- which is already the primary surface color out of the box on a clean Android Studio project). I'm targeting Material Design 3 UI guidelines.
There are various existing answers for previous versions of android, of varying quality, that involve running down a fairly lengthy rabbit hole of styles and themes to capture errant pieces of UI in a toolbar (icons, menus &c). In various previous incarnations of android there have been theme overlays, and theme variants that produce light/light-toolbar or dark/dark-toolbar apps. But none of those hooks seem to be there for Material3 -- which by DESIGN is supposed to have same-color toolbars.
With relatively default configuration, my Toolbars are (I think) primary color background, with white text during the day, and black (primary?) text on white background at night (inverted with respect to primary and secondary surfaces). And I can't find a moral equivalent of light-toolbar light background for Day/Night themes that will hopefully respect wallpaper matched colors for those that have android 12++ (I do).
I feel like I'm missing something simple here.
Fwiw, I'm NOT using CoordinatoryLayout/AppLayout -- just a naked Toolbar, due to previous unpleasant wrangles with CoordinatorLayout and running Activites in full-screen mode, which I will be doing with this project as well. (CoordinatorLayout gives me nothing I want, and breaks a lot that I do want).
I did try setting explicit colors on the toolbar, and came running here when the icon didn't change color. (I've been down this road before, on at least three versions of Android. :-P).
The app is a freshly created (about a week old) Android app, created using Android studio with latest SDK. App themes seem to have been pointed at material 2, although all dependencies are up to date for Material 3. Hard to say; all of the Android docs tell you how to migrate old apps, not how to create new ones -- a curious omission.
Would by nice to see your code. But I was with a similar problem. According with documentation, the default value for a Toolbar background is ?attr/colorSurface and it is set on android:background. So, I solved overriding toolbar style.
<style name="Theme.Custom" parent="Theme.Material3.Dark">
<item name="toolbarStyle">#style/Theme.Custom.Toolbar</item>
</style>
<style name="Theme.Custom.Toolbar" parent="Widget.Material3.Toolbar">
<item name="android:background">#color/your_color</item>
</style>
I hope that this help you.
Trying to add Dark Mode to my app. I am mostly there, most things work as I expect after I made the required changes, however I have a problem with the Toolbar. What have I missed?
Screenshot of Toolbar issue, and layout
You're applying AppTheme to popupTheme, what does it have?
You don't usually need to make a custom one, one of the pre-made ones like ThemeOverlay.MaterialComponents.Toolbar is enough.
And actually, if you're using MaterialComponents, you don't need to apply anything to your app to make it work in Dark Mode, just use the DayNight MaterialComponents theme.
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.
I went to the navigation drawer tutorial site where it gave me a link to download the holo icons for the action bar.
There were two directories, one for Holo Light and one for Holo Dark. Both icons, however, looked exactly the same to me. It appears as both are the Holo Light icon.
How can I get the Holo Dark icon?
Look here:
http://developer.android.com/training/implementing-navigation/nav-drawer.html
It should be also in other places soon.
Looking at the icon downloads that you are referring to (as linked in the other answer, and tagged with the date 20130516) it appears to me that they are similar but not the same.
I'm not saying they are well suited to their themes (and I certainly wouldn't put it past Google to make the sort of mistake that you suspect) but in fact I believe they are correct.
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..