robinmanuelthiel / flexbutton

Flexible button control for Xamarin.Forms
MIT License
240 stars 34 forks source link

Create Button in csharp #56

Closed acaliaro closed 5 years ago

acaliaro commented 6 years ago

Describe the bug I have different output creating FlexButton in code VS xaml

To Reproduce public static FlexButton CreateFlexButton(string text = null) {

        FlexButton flexButton = new FlexButton();
        if (!String.IsNullOrEmpty(text))
            flexButton.Text = text;

        flexButton.HorizontalOptions = LayoutOptions.Center;
        flexButton.WidthRequest = 300;
        flexButton.HeightRequest = 80;
        flexButton.CornerRadius = 22;
        flexButton.BorderColor = Color.FromHex("#49516F");
        flexButton.HighlightBorderColor = Color.FromHex("#6279B8"/*"#f28e02"*/);
        flexButton.ForegroundColor = Color.FromHex("#ffffff");
        flexButton.HighlightForegroundColor = Color.FromHex("#49516F");
        flexButton.BackgroundColor = (Color) Application.Current.Resources["MyColor"];
        flexButton.HighlightBackgroundColor = Color.FromHex("#8EA4D2");
        flexButton.FontSize = 30;

        return flexButton;

    }

I think I should see text center aligned and the shadow on the bottom of each button, as I see in your xaml example

        <flex:FlexButton
            x:Name="WideButton"
            ClickedCommand="{Binding ButtonClickedCommand}"
            IconOrientation="Right"
            HorizontalOptions="Center"
            WidthRequest="300"
            HeightRequest="76"
            CornerRadius="22"
            Icon="lightbulb.png"
            Text="Icon and Text"
            BorderThickness="0,0,0,4"
            BorderColor="#49516F"
            HighlightBorderColor="#6279B8"
            ForegroundColor="#ffffff"
            HighlightForegroundColor="#49516F"
            BackgroundColor="#6279B8"
            HighlightBackgroundColor="#8EA4D2"/>

Expected behavior center text and shadow at the bottom

Screenshots I have this output on a Nexus 7.1 Android API 25 emulator

image

Please complete the following information:

acaliaro commented 6 years ago

Hi @robinmanuelthiel

Do you have some news about "alignment" problem?

I have tested again in a real device and it works

image

But using the same code on a popup https://github.com/rotorgames/Rg.Plugins.Popup I have the problem

image

This is the code I use

    public static FlexButton CreateFlexButton(string text = null)
    {

        FlexButton flexButton = new FlexButton();
        if (!String.IsNullOrEmpty(text))
            flexButton.Text = text;

        flexButton.HorizontalOptions = LayoutOptions.Center;
        flexButton.WidthRequest = 300;
        flexButton.HeightRequest = 65;
        flexButton.CornerRadius = 10;
        flexButton.BorderColor = Color.FromHex("#49516F");
        flexButton.HighlightBorderColor = Color.FromHex("#6279B8"/*"#f28e02"*/);
        flexButton.ForegroundColor = Color.FromHex("#ffffff");
        flexButton.HighlightForegroundColor = Color.FromHex("#49516F");
        flexButton.BackgroundColor = (Color)Application.Current.Resources["MyColor"];
        flexButton.HighlightBackgroundColor = (Color)Application.Current.Resources["FlexColorBackground"];
        flexButton.FontSize = 24;

        return flexButton;

    }

Thanks

robinmanuelthiel commented 5 years ago

Can you please check, if this has been fixed in version 0.9.0? I completely re-build the centering logic. https://www.nuget.org/packages/Forms.Controls.FlexButton/0.9.0

acaliaro commented 5 years ago

Thanks @robinmanuelthiel . For this project I have used native Button because of this problem… I will take a look in the next project Thanks again