Forum General

Button text always showing in uppercase

SreeeeSreeee INMember ✭✭✭✭✭

Dears,

In my xamarin forms project button text are always show in uppercase format.
But I am providing upper and lower case letters in xaml. When I build the solution all the letters are changed to uppercase.

Any solution.
Thanks in advance.

Best Answers

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    you should write to "Xamarin Forms" forum, not under "General"

    is an iOS or Android problem?

  • SreeeeSreeee INMember ✭✭✭✭✭

    Hi @AlessandroCaliaro Thanks for your suggestion when posting.
    In android only I am facing this problem...

  • SreeeeSreeee INMember ✭✭✭✭✭

    Hi @AlessandroCaliaro
    When I add the code to cs file getting some errors.

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    It's for Android prj... you should use it in a customrenderer

  • nanomanonanomano USMember ✭✭

    @Sreeee said:
    Solved by adding the following to your styles.xml file which can be found in the Android project under the Resources then values folders.

         <item name="android:textAllCaps">false</item>
    

    Hi @AlessandroCaliaro Thanks for your attention....

    This is the simplest solution and works like a charm. for more information on styles and android themes this is an excellent tutorial series https://medium.com/mindorks/mastering-android-themes-chapter-1-4aadfa750ca7

  • cruzier007cruzier007 Member ✭✭

    Hi Guys,

    I have found one solution that works for me and I have posted here

    Solutions for this issue that works for me in android and iOS for material to avoid automatic UpperCase conversion when Visual is set to "Material".

    Xamarin.Forms.Android:

    <style name="MainTheme" parent="MainTheme.Base">
        <item name="android:textAllCaps">false</item>
    </style>
    

    Xamarin.Forms.iOS:

    [assembly: ExportRenderer(typeof(Button), typeof(ButtonRendererEx), new[] { typeof(VisualMarker.MaterialVisual) })]
    namespace GettingStarted.iOS
    {
        public class ButtonRendererEx : MaterialButtonRenderer
        {
            protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
            {
                base.OnElementChanged(e);
    
                if (Control != null)
                {
                    Control.UppercaseTitle = false;
                }
            }
        }
    }
    
  • @cruzier007 said:
    Hi Guys,

    I have found one solution that works for me and I have posted here

    Solutions for this issue that works for me in android and iOS for material to avoid automatic UpperCase conversion when Visual is set to "Material".

    Xamarin.Forms.Android:

    <style name="MainTheme" parent="MainTheme.Base">
        <item name="android:textAllCaps">false</item>
    </style>
    

    Xamarin.Forms.iOS:

    [assembly: ExportRenderer(typeof(Button), typeof(ButtonRendererEx), new[] { typeof(VisualMarker.MaterialVisual) })]
    namespace GettingStarted.iOS
    {
        public class ButtonRendererEx : MaterialButtonRenderer
        {
            protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
            {
                base.OnElementChanged(e);
    
                if (Control != null)
                {
                    Control.UppercaseTitle = false;
                }
            }
        }
    }
    

    This way is really better. Everything works as it should. Thanks for sharing, I think it will help a lot in the future.

Sign In or Register to comment.