Xamarin.Forms issue with button with border?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I have this button:



 <Button x:Name="btnNext" BorderWidth="2" BorderColor="#96AF5B" BorderRadius="4" 
WidthRequest="110" HeightRequest="25" Padding="0" VerticalOptions="Center" HorizontalOptions="Center"
BackgroundColor="#FFFCFF" FontSize="Default"

RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Width,Factor=0.5, Constant=-55}"

RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView,
ElementName=videoPlayer,Property=Height,Factor=0.85, Constant=12.5}" FontFamily="verdana"
Clicked="Next_Clicked"/>


in Android, it shows a little square at the top left side of the button when tapped, this also happens when using a frame instead of setting the button's border properties.



here's a gif:
https://i.stack.imgur.com/FGv5j.gif










share|improve this question

























  • If you use frame, did you try setting the IsClippedToBounds property to true?

    – hashimks
    Nov 23 '18 at 6:17


















0















I have this button:



 <Button x:Name="btnNext" BorderWidth="2" BorderColor="#96AF5B" BorderRadius="4" 
WidthRequest="110" HeightRequest="25" Padding="0" VerticalOptions="Center" HorizontalOptions="Center"
BackgroundColor="#FFFCFF" FontSize="Default"

RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Width,Factor=0.5, Constant=-55}"

RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView,
ElementName=videoPlayer,Property=Height,Factor=0.85, Constant=12.5}" FontFamily="verdana"
Clicked="Next_Clicked"/>


in Android, it shows a little square at the top left side of the button when tapped, this also happens when using a frame instead of setting the button's border properties.



here's a gif:
https://i.stack.imgur.com/FGv5j.gif










share|improve this question

























  • If you use frame, did you try setting the IsClippedToBounds property to true?

    – hashimks
    Nov 23 '18 at 6:17














0












0








0








I have this button:



 <Button x:Name="btnNext" BorderWidth="2" BorderColor="#96AF5B" BorderRadius="4" 
WidthRequest="110" HeightRequest="25" Padding="0" VerticalOptions="Center" HorizontalOptions="Center"
BackgroundColor="#FFFCFF" FontSize="Default"

RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Width,Factor=0.5, Constant=-55}"

RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView,
ElementName=videoPlayer,Property=Height,Factor=0.85, Constant=12.5}" FontFamily="verdana"
Clicked="Next_Clicked"/>


in Android, it shows a little square at the top left side of the button when tapped, this also happens when using a frame instead of setting the button's border properties.



here's a gif:
https://i.stack.imgur.com/FGv5j.gif










share|improve this question
















I have this button:



 <Button x:Name="btnNext" BorderWidth="2" BorderColor="#96AF5B" BorderRadius="4" 
WidthRequest="110" HeightRequest="25" Padding="0" VerticalOptions="Center" HorizontalOptions="Center"
BackgroundColor="#FFFCFF" FontSize="Default"

RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Width,Factor=0.5, Constant=-55}"

RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView,
ElementName=videoPlayer,Property=Height,Factor=0.85, Constant=12.5}" FontFamily="verdana"
Clicked="Next_Clicked"/>


in Android, it shows a little square at the top left side of the button when tapped, this also happens when using a frame instead of setting the button's border properties.



here's a gif:
https://i.stack.imgur.com/FGv5j.gif







xamarin xamarin.forms xamarin.android






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 8:00







mshwf

















asked Nov 22 '18 at 7:45









mshwfmshwf

2,33942257




2,33942257













  • If you use frame, did you try setting the IsClippedToBounds property to true?

    – hashimks
    Nov 23 '18 at 6:17



















  • If you use frame, did you try setting the IsClippedToBounds property to true?

    – hashimks
    Nov 23 '18 at 6:17

















If you use frame, did you try setting the IsClippedToBounds property to true?

– hashimks
Nov 23 '18 at 6:17





If you use frame, did you try setting the IsClippedToBounds property to true?

– hashimks
Nov 23 '18 at 6:17












1 Answer
1






active

oldest

votes


















0














Actually, this bug has been around for a while now if I am not wrong we started facing this issue around somewhere in mid of March and it has been there ever since.



If you check Bugzilla there are a ton of bugs that have been logged for all the issues that people are facing because of this:



https://bugzilla.xamarin.com/show_bug.cgi?id=58140



https://bugzilla.xamarin.com/show_bug.cgi?id=42351



https://bugzilla.xamarin.com/show_bug.cgi?id=60248



https://bugzilla.xamarin.com/show_bug.cgi?id=60392



So I went out and devised a workaround which seems to be working fine for us using Label and Stack layout with some customized changes:



  public class CustomButton: Label   
{
public static readonly BindableProperty CommandProperty =
BindableProperty.Create("Command", typeof(ICommand), typeof(CustomButton), null);

public static readonly BindableProperty CommandParameterProperty =
BindableProperty.Create("CommandParameter", typeof(object), typeof(CustomButton), null);

public event EventHandler ItemTapped = ( e, a ) => { };

public CustomButton()
{
Initialize();
}

public ICommand Command
{
get { return (ICommand)GetValue(CommandProperty); }
set { SetValue(CommandProperty, value); }
}

public object CommandParameter
{
get { return GetValue(CommandParameterProperty); }
set { SetValue(CommandParameterProperty, value); }
}

private ICommand TransitionCommand
{
get
{
return new Command(async () =>
{
AnchorX=0.48;
AnchorY=0.48;
await this.ScaleTo(0.8, 50, Easing.Linear);
await Task.Delay(100);
await this.ScaleTo(1, 50, Easing.Linear);
Command?.Execute(CommandParameter);

ItemTapped(this, EventArgs.Empty);
});
}
}

public void Initialize()
{
GestureRecognizers.Add(new TapGestureRecognizer
{
Command=TransitionCommand
});
}
}


I have also added a little animation so it gives the feel for a button.



Then use this Label as follows:



 <StackLayout BackgroundColor="Black" Padding="1"> // Here padding will be the border size you want and background color will be the color for it 
<nameSpace:CustomButton XAlign="Center" BackgroundColor="Blue" /> //Height and Width request is mandatory here
</StackLayout>


The only problem with this solution is that you cannot add border-radius.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426098%2fxamarin-forms-issue-with-button-with-border%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Actually, this bug has been around for a while now if I am not wrong we started facing this issue around somewhere in mid of March and it has been there ever since.



    If you check Bugzilla there are a ton of bugs that have been logged for all the issues that people are facing because of this:



    https://bugzilla.xamarin.com/show_bug.cgi?id=58140



    https://bugzilla.xamarin.com/show_bug.cgi?id=42351



    https://bugzilla.xamarin.com/show_bug.cgi?id=60248



    https://bugzilla.xamarin.com/show_bug.cgi?id=60392



    So I went out and devised a workaround which seems to be working fine for us using Label and Stack layout with some customized changes:



      public class CustomButton: Label   
    {
    public static readonly BindableProperty CommandProperty =
    BindableProperty.Create("Command", typeof(ICommand), typeof(CustomButton), null);

    public static readonly BindableProperty CommandParameterProperty =
    BindableProperty.Create("CommandParameter", typeof(object), typeof(CustomButton), null);

    public event EventHandler ItemTapped = ( e, a ) => { };

    public CustomButton()
    {
    Initialize();
    }

    public ICommand Command
    {
    get { return (ICommand)GetValue(CommandProperty); }
    set { SetValue(CommandProperty, value); }
    }

    public object CommandParameter
    {
    get { return GetValue(CommandParameterProperty); }
    set { SetValue(CommandParameterProperty, value); }
    }

    private ICommand TransitionCommand
    {
    get
    {
    return new Command(async () =>
    {
    AnchorX=0.48;
    AnchorY=0.48;
    await this.ScaleTo(0.8, 50, Easing.Linear);
    await Task.Delay(100);
    await this.ScaleTo(1, 50, Easing.Linear);
    Command?.Execute(CommandParameter);

    ItemTapped(this, EventArgs.Empty);
    });
    }
    }

    public void Initialize()
    {
    GestureRecognizers.Add(new TapGestureRecognizer
    {
    Command=TransitionCommand
    });
    }
    }


    I have also added a little animation so it gives the feel for a button.



    Then use this Label as follows:



     <StackLayout BackgroundColor="Black" Padding="1"> // Here padding will be the border size you want and background color will be the color for it 
    <nameSpace:CustomButton XAlign="Center" BackgroundColor="Blue" /> //Height and Width request is mandatory here
    </StackLayout>


    The only problem with this solution is that you cannot add border-radius.






    share|improve this answer




























      0














      Actually, this bug has been around for a while now if I am not wrong we started facing this issue around somewhere in mid of March and it has been there ever since.



      If you check Bugzilla there are a ton of bugs that have been logged for all the issues that people are facing because of this:



      https://bugzilla.xamarin.com/show_bug.cgi?id=58140



      https://bugzilla.xamarin.com/show_bug.cgi?id=42351



      https://bugzilla.xamarin.com/show_bug.cgi?id=60248



      https://bugzilla.xamarin.com/show_bug.cgi?id=60392



      So I went out and devised a workaround which seems to be working fine for us using Label and Stack layout with some customized changes:



        public class CustomButton: Label   
      {
      public static readonly BindableProperty CommandProperty =
      BindableProperty.Create("Command", typeof(ICommand), typeof(CustomButton), null);

      public static readonly BindableProperty CommandParameterProperty =
      BindableProperty.Create("CommandParameter", typeof(object), typeof(CustomButton), null);

      public event EventHandler ItemTapped = ( e, a ) => { };

      public CustomButton()
      {
      Initialize();
      }

      public ICommand Command
      {
      get { return (ICommand)GetValue(CommandProperty); }
      set { SetValue(CommandProperty, value); }
      }

      public object CommandParameter
      {
      get { return GetValue(CommandParameterProperty); }
      set { SetValue(CommandParameterProperty, value); }
      }

      private ICommand TransitionCommand
      {
      get
      {
      return new Command(async () =>
      {
      AnchorX=0.48;
      AnchorY=0.48;
      await this.ScaleTo(0.8, 50, Easing.Linear);
      await Task.Delay(100);
      await this.ScaleTo(1, 50, Easing.Linear);
      Command?.Execute(CommandParameter);

      ItemTapped(this, EventArgs.Empty);
      });
      }
      }

      public void Initialize()
      {
      GestureRecognizers.Add(new TapGestureRecognizer
      {
      Command=TransitionCommand
      });
      }
      }


      I have also added a little animation so it gives the feel for a button.



      Then use this Label as follows:



       <StackLayout BackgroundColor="Black" Padding="1"> // Here padding will be the border size you want and background color will be the color for it 
      <nameSpace:CustomButton XAlign="Center" BackgroundColor="Blue" /> //Height and Width request is mandatory here
      </StackLayout>


      The only problem with this solution is that you cannot add border-radius.






      share|improve this answer


























        0












        0








        0







        Actually, this bug has been around for a while now if I am not wrong we started facing this issue around somewhere in mid of March and it has been there ever since.



        If you check Bugzilla there are a ton of bugs that have been logged for all the issues that people are facing because of this:



        https://bugzilla.xamarin.com/show_bug.cgi?id=58140



        https://bugzilla.xamarin.com/show_bug.cgi?id=42351



        https://bugzilla.xamarin.com/show_bug.cgi?id=60248



        https://bugzilla.xamarin.com/show_bug.cgi?id=60392



        So I went out and devised a workaround which seems to be working fine for us using Label and Stack layout with some customized changes:



          public class CustomButton: Label   
        {
        public static readonly BindableProperty CommandProperty =
        BindableProperty.Create("Command", typeof(ICommand), typeof(CustomButton), null);

        public static readonly BindableProperty CommandParameterProperty =
        BindableProperty.Create("CommandParameter", typeof(object), typeof(CustomButton), null);

        public event EventHandler ItemTapped = ( e, a ) => { };

        public CustomButton()
        {
        Initialize();
        }

        public ICommand Command
        {
        get { return (ICommand)GetValue(CommandProperty); }
        set { SetValue(CommandProperty, value); }
        }

        public object CommandParameter
        {
        get { return GetValue(CommandParameterProperty); }
        set { SetValue(CommandParameterProperty, value); }
        }

        private ICommand TransitionCommand
        {
        get
        {
        return new Command(async () =>
        {
        AnchorX=0.48;
        AnchorY=0.48;
        await this.ScaleTo(0.8, 50, Easing.Linear);
        await Task.Delay(100);
        await this.ScaleTo(1, 50, Easing.Linear);
        Command?.Execute(CommandParameter);

        ItemTapped(this, EventArgs.Empty);
        });
        }
        }

        public void Initialize()
        {
        GestureRecognizers.Add(new TapGestureRecognizer
        {
        Command=TransitionCommand
        });
        }
        }


        I have also added a little animation so it gives the feel for a button.



        Then use this Label as follows:



         <StackLayout BackgroundColor="Black" Padding="1"> // Here padding will be the border size you want and background color will be the color for it 
        <nameSpace:CustomButton XAlign="Center" BackgroundColor="Blue" /> //Height and Width request is mandatory here
        </StackLayout>


        The only problem with this solution is that you cannot add border-radius.






        share|improve this answer













        Actually, this bug has been around for a while now if I am not wrong we started facing this issue around somewhere in mid of March and it has been there ever since.



        If you check Bugzilla there are a ton of bugs that have been logged for all the issues that people are facing because of this:



        https://bugzilla.xamarin.com/show_bug.cgi?id=58140



        https://bugzilla.xamarin.com/show_bug.cgi?id=42351



        https://bugzilla.xamarin.com/show_bug.cgi?id=60248



        https://bugzilla.xamarin.com/show_bug.cgi?id=60392



        So I went out and devised a workaround which seems to be working fine for us using Label and Stack layout with some customized changes:



          public class CustomButton: Label   
        {
        public static readonly BindableProperty CommandProperty =
        BindableProperty.Create("Command", typeof(ICommand), typeof(CustomButton), null);

        public static readonly BindableProperty CommandParameterProperty =
        BindableProperty.Create("CommandParameter", typeof(object), typeof(CustomButton), null);

        public event EventHandler ItemTapped = ( e, a ) => { };

        public CustomButton()
        {
        Initialize();
        }

        public ICommand Command
        {
        get { return (ICommand)GetValue(CommandProperty); }
        set { SetValue(CommandProperty, value); }
        }

        public object CommandParameter
        {
        get { return GetValue(CommandParameterProperty); }
        set { SetValue(CommandParameterProperty, value); }
        }

        private ICommand TransitionCommand
        {
        get
        {
        return new Command(async () =>
        {
        AnchorX=0.48;
        AnchorY=0.48;
        await this.ScaleTo(0.8, 50, Easing.Linear);
        await Task.Delay(100);
        await this.ScaleTo(1, 50, Easing.Linear);
        Command?.Execute(CommandParameter);

        ItemTapped(this, EventArgs.Empty);
        });
        }
        }

        public void Initialize()
        {
        GestureRecognizers.Add(new TapGestureRecognizer
        {
        Command=TransitionCommand
        });
        }
        }


        I have also added a little animation so it gives the feel for a button.



        Then use this Label as follows:



         <StackLayout BackgroundColor="Black" Padding="1"> // Here padding will be the border size you want and background color will be the color for it 
        <nameSpace:CustomButton XAlign="Center" BackgroundColor="Blue" /> //Height and Width request is mandatory here
        </StackLayout>


        The only problem with this solution is that you cannot add border-radius.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 8:09









        G.hakimG.hakim

        5,41711136




        5,41711136
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426098%2fxamarin-forms-issue-with-button-with-border%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Guess what letter conforming each word

            Port of Spain

            Run scheduled task as local user group (not BUILTIN)