Forum Xamarin Xamarin.Forms

Label MaxLines behaves differently on Android and iOS. Is this intended, or can it be fixed?

Cliff2103Cliff2103 Member ✭✭
edited July 13 in Xamarin.Forms

In our app we want a Label to expand when it is tapped. We're trying to do this by adding a binding on the MaxLines property of the label. When the label is not clicked it is set to 2, which indeed shows two lines on both Android and iOS. But when we when the label is tapped and we want to expand it we set the MaxLines property to 0. On iOS this does exactly what we want and expand the label, but on Android it really shows 0 lines, is this intended behaviour? Will it be fixed in Xamarin, or can we somehow work around it? Any help is appreciated.

Answers

  • Cliff2103Cliff2103 Member ✭✭
    edited July 13

    We now work around it by just switching MaxLines between 2 and 1000. Which does work, but feels a bit hacky in my opinion, so I still would appreciate any help.

  • JohnHardmanJohnHardman GBUniversity admin
    edited July 13

    @Cliff2103 said:
    In our app we want a Label to expand when it is tapped. We're trying to do this by adding a binding on the MaxLines property of the label. When the label is not clicked it is set to 2, which indeed shows two lines on both Android and iOS. But when we when the label is tapped and we want to expand it we set the MaxLines property to 0. On iOS this does exactly what we want and expand the label, but on Android it really shows 0 lines, is this intended behaviour? Will it be fixed in Xamarin, or can we somehow work around it? Any help is appreciated.

    What happens if you set MaxLines to -1 instead of 0 ? (-1 is the default value)

  • Cliff2103Cliff2103 Member ✭✭

    @JohnHardman said:

    @Cliff2103 said:
    In our app we want a Label to expand when it is tapped. We're trying to do this by adding a binding on the MaxLines property of the label. When the label is not clicked it is set to 2, which indeed shows two lines on both Android and iOS. But when we when the label is tapped and we want to expand it we set the MaxLines property to 0. On iOS this does exactly what we want and expand the label, but on Android it really shows 0 lines, is this intended behaviour? Will it be fixed in Xamarin, or can we somehow work around it? Any help is appreciated.

    What happens if you set MaxLines to -1 instead of 0 ? (-1 is the default value)

    That doesn't work on both platforms. -1 seems to be taken as just 1.

  • JohnHardmanJohnHardman GBUniversity admin

    @Cliff2103 said:

    @JohnHardman said:
    What happens if you set MaxLines to -1 instead of 0 ? (-1 is the default value)

    That doesn't work on both platforms. -1 seems to be taken as just 1.

    In which case, I'd suggest logging an issue at https://github.com/xamarin/Xamarin.Forms/issues

  • Cliff2103Cliff2103 Member ✭✭

    Bug report can be found at: https://github.com/xamarin/Xamarin.Forms/issues/11427 if you'd like to track this issue.

Sign In or Register to comment.