Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control won't fit the full width of the container #3

Open
softlion opened this issue Feb 21, 2024 · 2 comments
Open

Control won't fit the full width of the container #3

softlion opened this issue Feb 21, 2024 · 2 comments

Comments

@softlion
Copy link

On android, the tabs are not filling the whole container.

In the image below, the background color of the SegmentedControl is made yellow.

But the tabs are not fully extended to the size of the container. Any idea why ?

image

<ContentPage
    x:Class="MauiApp1.Views.MainPage"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:d="http://schemas.microsoft.com/dotnet/2021/maui/design"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:segmentedControl="clr-namespace:Plugin.Maui.SegmentedControl;assembly=Plugin.Maui.SegmentedControl"
    Title="MauiApp1"
    BackgroundColor="Wheat"
    mc:Ignorable="d">
        <VerticalStackLayout BackgroundColor="Red">

            <Label Text="Bonjour" HorizontalOptions="Fill" BackgroundColor="LightGreen" />
            
            <segmentedControl:SegmentedControl TintColor="#007AFF" SelectedSegment="0" 
                                               HorizontalOptions="Fill" BackgroundColor="Yellow">
                <segmentedControl:SegmentedControl.Children>
                    <segmentedControl:SegmentedControlOption Text="Tab 1" />
                    <segmentedControl:SegmentedControlOption Text="Tab 2" />
                    <segmentedControl:SegmentedControlOption Text="Tab 3" />
                    <segmentedControl:SegmentedControlOption Text="Tab 4" />
                </segmentedControl:SegmentedControl.Children>
            </segmentedControl:SegmentedControl>
            
        </VerticalStackLayout>
</ContentPage>
@yurkinh
Copy link
Owner

yurkinh commented Feb 21, 2024

Hi @softlion
As a workaround use please WidthRequest.
I will take a look at this issue

@smalgin
Copy link

smalgin commented Mar 15, 2024

@yurkinh @softlion - see this branch https://github.com/smalgin/Plugin.Maui.SegmentedControl/tree/smalgin/moreFunc

I added a minimal set of functionality to make a control actually usable beyond 'fixed set of tabs' use case.

  • Children property is bindable
  • more colors
  • segment text is bindable via XAML/viewmodel
  • segment isEnabled works
  • SelectedSegment is bindable two-way
  • fixed the Çontrol won't fit the full width' issue on Android.

TODO before I submit PR:

  • add iOS changes
  • add MacCatalyst changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants