xamarin / XamarinCommunityToolkit

The Xamarin Community Toolkit is a collection of Animations, Behaviors, Converters, and Effects for mobile development with Xamarin.Forms. It simplifies and demonstrates common developer tasks building iOS, Android, and UWP apps with Xamarin.Forms.
MIT License
1.58k stars 471 forks source link

BadgeView doesn't work on Horizontal options like FillAndExpand[Bug] #1317

Open Brosten opened 3 years ago

Brosten commented 3 years ago

Description

The badgeview makes HorizontalOptions of the control it surrounds out of order.

Steps to Reproduce

Try this <xct:BadgeView BackgroundColor="Red" FontAttributes="Bold" FontSize="Medium" TextColor="White" Text="1"> <Button Text="This label has a badge in the top-right" HorizontalOptions="FillAndExpand"/> </xct:BadgeView>

Expected Behavior

The button above should use the complete width of the badges parent.

Actual Behavior

The width of the button is set depending of the text on the button, not the horizontaloptions.

Basic Information

Workaround

Setting the WidthRequest of the button will do the trick, but I don't wan't to use that one since it's not flexible

IgorKravchenko10 commented 3 years ago

Yeah, I have the same issue. FillAndExpand does not work. By default Button is expanded to full width. The button wrapped by BadgeView has it's text width.

maxchu92 commented 3 years ago

Having the same issue as well. Setting FillAndExpand on either the badge or its contents doesnt work

Version: 1.2.0 Platform tested: Android 11

proudust commented 2 years ago

https://github.com/xamarin/XamarinCommunityToolkit/blob/bb147a47ba82ae546e37b72704ca21ad7b256c3f/src/CommunityToolkit/Xamarin.CommunityToolkit/Views/BadgeView/BadgeView.shared.cs#L262-L266

The cause of this issue is probably this method. However, changing this to LayoutOptions.Fill caused a SIGSEGV error on Android 12, so you'll need to figure out a workaround.