I am trying to get a mixture of lower & uppercase text on a button (rather than just the default upper case only) on Android Studio. I am aware I can use 'android:textAllCaps="false"', but this is only available for API 14 and above. Is there a way around this which I can use for API 10? Thanks
-
http://stackoverflow.com/a/30607625/115145 – CommonsWare Nov 25 '16 at 21:28
-
No, I'm afraid this method uses 'android:textAllCaps="false" – Matthew Whittenham Nov 25 '16 at 21:31
-
Did you try button.setTransformationMethod(null) – user3673952 Nov 25 '16 at 21:46
1 Answers
Step #1: Open app/src/main/res/values/styles.xml
. This should show a stub custom theme, inheriting from a Theme.AppCompat
-based theme, given your symptoms.
Step #2: Add a new <style>
to that file:
<style name="MixedCaseButton" parent="Widget.AppCompat.Button">
<item name="textAllCaps">false</item>
</style>
You will notice that this references textAllCaps
. The native implementation of textAllCaps
is new to API Level 14. This theme is using the backport of textAllCaps
supplied by appcompat-v7
, which you are using, given your symptoms.
Step #3: Add this element to your custom theme, the one that already existed in the styles.xml
file:
<item name="buttonStyle">@style/MixedCaseButton</item>
This will give you an overall styles.xml
file resembling:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="buttonStyle">@style/MixedCaseButton</item>
</style>
<style name="MixedCaseButton" parent="Widget.AppCompat.Button">
<item name="textAllCaps">false</item>
</style>
</resources>
(though the other contents of the pre-existing style resource may vary somewhat)
Step #4: Run your app, and you will see the button appear in mixed case. Please note that this violates the Material Design aesthetic.

- 986,068
- 189
- 2,389
- 2,491
-
Thanks a lot for that! Very clear instructions which work perfectly :) – Matthew Whittenham Nov 25 '16 at 22:48