yurkinh / Plugin.Maui.SegmentedControl

.NET MAUI Port of XF Segmented control
MIT License
14 stars 6 forks source link

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

Open softlion opened 8 months ago

softlion commented 8 months ago

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 commented 8 months ago

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

smalgin commented 7 months ago

@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.

TODO before I submit PR: