Xamarin.forms: [Bug] Cannot disable buttons text uppercase

Created on 25 Jul 2020  路  13Comments  路  Source: xamarin/Xamarin.Forms

Description

just got updated my project to xamarin.forms 4.8 pre 2 and this style
<item name="android:textAllCaps">false</item>
in android resorces somehow not working anymore!

Steps to Reproduce

  1. upgrade to xamarin.forms 4.8
  2. create a button
  3. use textAllCap style item in android resorces

Expected Behavior

disable buttons text uppercase

Actual Behavior

buttons text still are uppercase

Basic Information

  • Version with issue:
  • Last known good version:
  • IDE: Visual studio 16.6.5
  • Android: 10
  • Nuget Packages: Xamarin.Forms 4.8
button 5 regression high impact mobcat Android bug

Most helpful comment

The below custom renderer fixes the issue for the time being.

using Android.Content;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(Button), typeof(CustomButtonRenderer))]
namespace somenamespacename
{
public class CustomButtonRenderer : ButtonRenderer
{
public CustomButtonRenderer(Context context) : base(context)
{
}

    protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
    {
        base.OnElementChanged(e);
        Control.SetAllCaps(false);
    }
}

}

All 13 comments

Run this, then update it to 4.8 pre2 and run it again - the uppercase returns.
_11556 Repro.zip

This problem persists in Xamarin.Forms 4.8.0.1269. Can someone let me know if any workaround is there to fix that? In recent times for last one year or so, I could keep seeing issue like this in each Xamarin.Forms release which stops us to upgrade to latest version. Many issues are there with CarouselView, CollectionView, ImageButton and now in Buttons etc. I don't know how far the QA process is done.

@poliahrameshkumar Exactly :( i can't upgrade our project to 4.8.0.1269 because of this.

The below custom renderer fixes the issue for the time being.

using Android.Content;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(Button), typeof(CustomButtonRenderer))]
namespace somenamespacename
{
public class CustomButtonRenderer : ButtonRenderer
{
public CustomButtonRenderer(Context context) : base(context)
{
}

    protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
    {
        base.OnElementChanged(e);
        Control.SetAllCaps(false);
    }
}

}

i was exactly thinking about using a custom renderer :) thank you so much.

just found out the TextTransform property works for buttons too and is a perfect replacement for the old android resorces and custom renderer Workaround :) so our project is now upgraded to 4.8. 馃帀

@poliahrameshkumar thanks your fix saved me today! for some reasons the
"\false in our style.xml in android no longer works and only the renderer fix it.

Kind of confused what the behavior should be, as we definitely do not want to be all caps true

thanks again for the fix

Xamarin-Forms-4.8 : We can set Button property TextTransform="None" to fix all-caps android issue.

Note: This will not work for the button of type Visual="Material".

You saved my life guys with TextTransform 鉂わ笍

@ananth-more1-gmail you saved my day
it works, thanks

@ananth-more1-gmail thank you
馃憤

Xamarin-Forms-4.8 : We can set Button property TextTransform="None" to fix all-caps android issue.

Note: This will not work for the button of type Visual="Material".

@ananth-more1-gmail If I didn't miss a build/clean/rebuild, it works for Visual Material buttons too with 4.8.0.1534 ^_^

Xamarin-Forms-4.8 : We can set Button property TextTransform="None" to fix all-caps android issue.

Note: This will not work for the button of type Visual="Material".

Thank you

Was this page helpful?
0 / 5 - 0 ratings