Xamarin Android Add Button Text All Caps - How to apply a style in an application?

I am new to mobile development, I am developing a simple application using the Xamarin studio and have added a few buttons on my page. I noticed that all text buttons appear in CAPITAL LETTERS when I run it in the emulator (Android 5.0.1 - API 21).

I have already followed Why is my button text forced on ALL CAPS on Lollipop? and tried adding <item name="android:textAllCaps">false</item> to my style.xml, but it doesn’t make any difference.

Also checked Why is my button text forcibly displayed on ALL CAPS on Lollipop? and Button text for Android 5.0 widget (Lollipop) are in ALL CAPS .

If I add android:textAllCaps = "false" to my all buttons (in my axml files) then it will work, but I want to know the generalized style for all buttons in the application (in several forms / actions)

Can anyone suggest a way to use any style in the application?

Thanks.

+6
source share
1 answer

You can try adding the following to the Resources / values ​​folder as styles.xml.

 <?xml version="1.0" encoding="UTF-8" ?> <resources> <!-- Inherit from the light Material Theme --> <style name="MyCustomTheme" parent="android:Theme.Material"> <!-- Customizations go here --> <item name="android:textAllCaps">false</item> </style> </resources> 

Then in your MainActivity.cs apply this custom theme

 [Activity(Label = "MyActivity", Theme = "@style/MyCustomTheme")] 
+14
source

Source: https://habr.com/ru/post/986743/


All Articles