Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Android Add button text all caps - How to apply style across the application?

I am new to mobile development, I am developing a simple app using Xamarin studio and added few buttons on my page. I noticed that all button texts are appeared in CAPITAL LETTERS when i run it in emulator (Android 5.0.1 - API 21).

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

Also checked Why is my Button text forced to ALL CAPS on Lollipop? and Android 5.0 (Lollipop) widget button's text 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 across the application (in multiple forms/activities even)

Can anyone please suggest a way to use some style across the application?

Thank you.

like image 308
Nilesh Thakkar Avatar asked May 07 '15 13:05

Nilesh Thakkar


1 Answers

You can try adding the following in your 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")]
like image 174
William Ku Avatar answered Nov 07 '22 22:11

William Ku