[AC-6499] Android Material Theme not working in SDK 9
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2020-04-08T02:21:19.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | android |
Reporter | Tony Lau |
Assignee | Abir Mukherjee |
Created | 2020-03-04T07:59:52.000+0000 |
Updated | 2020-04-08T02:21:19.000+0000 |
Description
Material them and custom button not working in SDK 9. Worked in 8.2.x
With the mytheme.xml, the buttons are supposed to be not with the standard grey rectangle and text should not in caps.
<resources>
<style name="materialTheme" parent="@style/Theme.AppCompat">
<item name="colorPrimary">#033047</item>
<item name="colorPrimaryDark">#4c6a7a</item>
<item name="colorAccent">#4d88a3</item>
<item name="colorControlNormal">#757575</item>
<item name="colorControlActivated">#FF6E40</item>
<item name="colorControlHighlight">#4d88a3</item>
<item name="colorSwitchThumbNormal">#BDBDBD</item>
<item name="android:colorButtonNormal">#0D0C05</item>
<item name="android:colorEdgeEffect">#4d88a3</item>
<item name="android:buttonStyle">@style/customButton</item>
</style>
<style name="customButton" parent="Widget.AppCompat.Button">
<item name="android:textAllCaps">false</item>
</style>
</resources>
Attachments
File | Date | Size |
---|---|---|
Android-kitchensink.png | 2020-03-07T04:30:25.000+0000 | 90461 |
This is likely an issue in your "AndroidManifest.xml" settings. We've switched to Google's newest gradle build tools, which is much more strict regarding your XML settings. For example, you need to make sure you have
@style/
prefixed in front of your theme name when referencing it in XML. Our "kitchensink-v2" sample app successfully overrides the theme in Titanium 9.0.0. Note that we reference it viaandroid:theme="@style/kitchensink"
in the "tiapp.xml" file where "kitchensink" is our custom theme/style. https://github.com/appcelerator/kitchensink-v2/blob/master/tiapp.xml https://github.com/appcelerator/kitchensink-v2/blob/master/app/platform/android/res/values/custom_theme.xmlI took the kitchensink theme and works fine. If I added the except the customButton section, that is the part that is not functioning. . .
This works for me...
Here is a screenshot of it working in kitchensink-v2. !Android-kitchensink.png|thumbnail!
I think it's an issue with your leading "android:" in...
This below works when I tested it on Android 4.4 and 9.0. My understanding is because the theme comes from Google's AndroidX library (or in the past the Support library) instead of the Android system library.
But I suppose if you're really paranoid, you can just define both. It won't hurt anything. :)
https://stackoverflow.com/a/31359459
No luck but I tested on real Android phones. Nexus 5X Android 8.1.0 Galaxy Note3 Android 5.0 For both devices, when I just switched back to 8.2.0GA, the lower caps showed up properly! A bit frustrating.
Without any more information, we can't help you. Especially since this is working for us. Do you see any warning or errors in the build log?
I final stumbled into how it can be reproduced. It has to do with how the controller is opened in modal or not. Alloy.createController('xxxxxxxxx').getView().open({modal:true}); ---> All text in button becomes all capital letters Alloy.createController('xxxxxxxxx').getView().open({modal:false}); ---> All text in button showed up as what were typed in code So, the problem is pertained to when windows are opened as modal.
Okay. I'm able to reproduce it now. Thanks for isolating it. A bug has been introduced into Titanium 9.0.0. Your custom style is being applied to the wrong translucent activity theme internally. If you need a solution now, then you can work-around it in 1 of 2 ways. *Work-Around 1:* Set the "theme" property to the below string when creating a window in code like this...
*Work-Around 2:* Set the theme of the "TiTranslucentActivity" like the below...
Note that the above 2 solutions are temporary, because the translucent activity theme is supposed to use "Theme.AppCompat.Translucent", not "Theme.AppCompat.Translucent" (it's currently backwards in 9.0.0). So, the above won't work in older Titanium versions... or future versions. We'll see about addressing it in 9.0.1. Thanks for reporting this issue.
I've written a ticket that better clarifies the issue here: [TIMOB-27837] I'm going to close this ticket in favor of the above one. We've scheduled it to be fixed in Titanium 9.0.1. Thanks for reporting this issue.