How to change Text Alignment of button on Android (Xamarin Forms)?Image size, placement in Image Button for Xamarin Forms LabsXamarin Forms bind property to label's textBinding Issues and OnAppearing issue with Xamarin Forms IOSXamarin Forms-Android: How to center align,change font size,font family of text in NavigationbarChange Xamarin Forms Android Navigation Page Colours (buttons & back)Android Tool Bar Center using Effects in Xamarin formsUsing Button with image and text in Xamarin FormsXamarin.Forms TitleView FillAndExpand not working with AndroidAdd button on map when pin/marker is clicked (xamarin forms)How can I make circular Progressbar with text in center

Why do all fields in a QFT transform like *irreducible* representations of some group?

Can you feel passing through the sound barrier in an F-16?

In an emergency, how do I find and share my position?

Cultural before-and-afters

Why did this happen to Thanos's ships at the end of "Avengers: Endgame"?

What is the best option for High availability on a data warehouse?

Why is Boris Johnson visiting only Paris & Berlin if every member of the EU needs to agree on a withdrawal deal?

Prove your innocence

Most practical knots for hitching a line to an object while keeping the bitter end as tight as possible, without sag?

Architectural feasibility of a tiered circular stone keep

Defense against attacks using dictionaries

I have a player who yells

How to respectfully refuse to assist co-workers with IT issues?

Are modern clipless shoes and pedals that much better than toe clips and straps?

Cross-referencing enumerate item

Did it used to be possible to target a zone?

What are some interesting features that are common cross-linguistically but don't exist in English?

Why isn't "I've" a proper response?

Fried gnocchi with spinach, bacon, cream sauce in a single pan

How to prevent cutting edges on my TV, HDMI-connected?

How would one country purchase another?

Did a flight controller ever answer Flight with a no-go?

Can realistic planetary invasion have any meaningful strategy?

Why in most German places is the church the tallest building?



How to change Text Alignment of button on Android (Xamarin Forms)?


Image size, placement in Image Button for Xamarin Forms LabsXamarin Forms bind property to label's textBinding Issues and OnAppearing issue with Xamarin Forms IOSXamarin Forms-Android: How to center align,change font size,font family of text in NavigationbarChange Xamarin Forms Android Navigation Page Colours (buttons & back)Android Tool Bar Center using Effects in Xamarin formsUsing Button with image and text in Xamarin FormsXamarin.Forms TitleView FillAndExpand not working with AndroidAdd button on map when pin/marker is clicked (xamarin forms)How can I make circular Progressbar with text in center






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















  • I use Xamarin Forms,

  • on iOS: Text Alignment of button display that nice

align_text_iOS



  • But on Android: Text Alignment of button always display "center"

align_text_Android



I can't find property change Text Alignment of button on Android.



On Android, I want to text align of button is "Start" or Change button of Android as same as button of iOS.



This is my code:



 <Button 
HeightRequest="15"
Text="Binding Phone2"
BackgroundColor="Aqua"
TextColor="x:Static color:BasePalette.DarkestColor"
HorizontalOptions="Start"
VerticalOptions="Center" />


Please support me!



Thanks!










share|improve this question
































    0















    • I use Xamarin Forms,

    • on iOS: Text Alignment of button display that nice

    align_text_iOS



    • But on Android: Text Alignment of button always display "center"

    align_text_Android



    I can't find property change Text Alignment of button on Android.



    On Android, I want to text align of button is "Start" or Change button of Android as same as button of iOS.



    This is my code:



     <Button 
    HeightRequest="15"
    Text="Binding Phone2"
    BackgroundColor="Aqua"
    TextColor="x:Static color:BasePalette.DarkestColor"
    HorizontalOptions="Start"
    VerticalOptions="Center" />


    Please support me!



    Thanks!










    share|improve this question




























      0












      0








      0








      • I use Xamarin Forms,

      • on iOS: Text Alignment of button display that nice

      align_text_iOS



      • But on Android: Text Alignment of button always display "center"

      align_text_Android



      I can't find property change Text Alignment of button on Android.



      On Android, I want to text align of button is "Start" or Change button of Android as same as button of iOS.



      This is my code:



       <Button 
      HeightRequest="15"
      Text="Binding Phone2"
      BackgroundColor="Aqua"
      TextColor="x:Static color:BasePalette.DarkestColor"
      HorizontalOptions="Start"
      VerticalOptions="Center" />


      Please support me!



      Thanks!










      share|improve this question
















      • I use Xamarin Forms,

      • on iOS: Text Alignment of button display that nice

      align_text_iOS



      • But on Android: Text Alignment of button always display "center"

      align_text_Android



      I can't find property change Text Alignment of button on Android.



      On Android, I want to text align of button is "Start" or Change button of Android as same as button of iOS.



      This is my code:



       <Button 
      HeightRequest="15"
      Text="Binding Phone2"
      BackgroundColor="Aqua"
      TextColor="x:Static color:BasePalette.DarkestColor"
      HorizontalOptions="Start"
      VerticalOptions="Center" />


      Please support me!



      Thanks!







      xamarin xamarin.forms xamarin.android xamarin.ios






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 27 at 16:51







      Leks G

















      asked Mar 27 at 16:36









      Leks GLeks G

      14 bronze badges




      14 bronze badges

























          2 Answers
          2






          active

          oldest

          votes


















          2















          What you are looking for is something like in this XLab Control



           public class ExtendedButton : Button

          /// <summary>
          /// Bindable property for button content vertical alignment.
          /// </summary>
          public static readonly BindableProperty VerticalContentAlignmentProperty =
          BindableProperty.Create<ExtendedButton, TextAlignment>(
          p => p.VerticalContentAlignment, TextAlignment.Center);

          /// <summary>
          /// Bindable property for button content horizontal alignment.
          /// </summary>
          public static readonly BindableProperty HorizontalContentAlignmentProperty =
          BindableProperty.Create<ExtendedButton, TextAlignment>(
          p => p.HorizontalContentAlignment, TextAlignment.Center);

          /// <summary>
          /// Gets or sets the content vertical alignment.
          /// </summary>
          public TextAlignment VerticalContentAlignment

          get return this.GetValue<TextAlignment>(VerticalContentAlignmentProperty);
          set this.SetValue(VerticalContentAlignmentProperty, value);


          /// <summary>
          /// Gets or sets the content horizontal alignment.
          /// </summary>
          public TextAlignment HorizontalContentAlignment

          get return this.GetValue<TextAlignment>(HorizontalContentAlignmentProperty);
          set this.SetValue(HorizontalContentAlignmentProperty, value);




          Android renderer:



          public class ExtendedButtonRenderer : ButtonRenderer

          /// <summary>
          /// Called when [element changed].
          /// </summary>
          /// <param name="e">The e.</param>
          protected override void OnElementChanged(ElementChangedEventArgs<Button> e)

          base.OnElementChanged(e);
          UpdateAlignment();
          UpdateFont();


          /// <summary>
          /// Handles the <see cref="E:ElementPropertyChanged" /> event.
          /// </summary>
          /// <param name="sender">The sender.</param>
          /// <param name="e">The <see cref="PropertyChangedEventArgs"/> instance containing the event data.</param>
          protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)


          /// <summary>
          /// Updates the font
          /// </summary>
          private void UpdateFont()

          Control.Typeface = Element.Font.ToExtendedTypeface(Context);


          /// <summary>
          /// Sets the alignment.
          /// </summary>
          private void UpdateAlignment()

          element.HorizontalContentAlignment.ToDroidHorizontalGravity();




          iOS Renderer:



           public class ExtendedButtonRenderer : ButtonRenderer

          /// <summary>
          /// Called when [element changed].
          /// </summary>
          /// <param name="e">The e.</param>
          protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
          this.Control == null)

          return;


          this.Control.VerticalAlignment = this.Element.VerticalContentAlignment.ToContentVerticalAlignment();
          this.Control.HorizontalAlignment = this.Element.HorizontalContentAlignment.ToContentHorizontalAlignment();


          /// <summary>
          /// Handles the <see cref="E:ElementPropertyChanged" /> event.
          /// </summary>
          /// <param name="sender">The sender.</param>
          /// <param name="e">The <see cref="PropertyChangedEventArgs"/> instance containing the event data.</param>
          protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)

          switch (e.PropertyName)

          case "VerticalContentAlignment":
          this.Control.VerticalAlignment = this.Element.VerticalContentAlignment.ToContentVerticalAlignment();
          break;
          case "HorizontalContentAlignment":
          this.Control.HorizontalAlignment = this.Element.HorizontalContentAlignment.ToContentHorizontalAlignment();
          break;
          default:
          base.OnElementPropertyChanged(sender, e);
          break;



          /// <summary>
          /// Gets the element.
          /// </summary>
          /// <value>The element.</value>
          public new ExtendedButton Element

          get

          return base.Element as ExtendedButton;





          Do not forget to add the ExportRenderer Attribute on both renderers [assembly: ExportRenderer(typeof(ExtendedButton), typeof(ExtendedButtonRenderer))]



          Goodluck feel free to revert in case of queries






          share|improve this answer


































            0















            You need to create a custom renderer for the button then in the customization of the control, call:



            button.Gravity = GravityFlags.Left;


            You will see your texts aligned to the left.






            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%2f55382294%2fhow-to-change-text-alignment-of-button-on-android-xamarin-forms%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2















              What you are looking for is something like in this XLab Control



               public class ExtendedButton : Button

              /// <summary>
              /// Bindable property for button content vertical alignment.
              /// </summary>
              public static readonly BindableProperty VerticalContentAlignmentProperty =
              BindableProperty.Create<ExtendedButton, TextAlignment>(
              p => p.VerticalContentAlignment, TextAlignment.Center);

              /// <summary>
              /// Bindable property for button content horizontal alignment.
              /// </summary>
              public static readonly BindableProperty HorizontalContentAlignmentProperty =
              BindableProperty.Create<ExtendedButton, TextAlignment>(
              p => p.HorizontalContentAlignment, TextAlignment.Center);

              /// <summary>
              /// Gets or sets the content vertical alignment.
              /// </summary>
              public TextAlignment VerticalContentAlignment

              get return this.GetValue<TextAlignment>(VerticalContentAlignmentProperty);
              set this.SetValue(VerticalContentAlignmentProperty, value);


              /// <summary>
              /// Gets or sets the content horizontal alignment.
              /// </summary>
              public TextAlignment HorizontalContentAlignment

              get return this.GetValue<TextAlignment>(HorizontalContentAlignmentProperty);
              set this.SetValue(HorizontalContentAlignmentProperty, value);




              Android renderer:



              public class ExtendedButtonRenderer : ButtonRenderer

              /// <summary>
              /// Called when [element changed].
              /// </summary>
              /// <param name="e">The e.</param>
              protected override void OnElementChanged(ElementChangedEventArgs<Button> e)

              base.OnElementChanged(e);
              UpdateAlignment();
              UpdateFont();


              /// <summary>
              /// Handles the <see cref="E:ElementPropertyChanged" /> event.
              /// </summary>
              /// <param name="sender">The sender.</param>
              /// <param name="e">The <see cref="PropertyChangedEventArgs"/> instance containing the event data.</param>
              protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)


              /// <summary>
              /// Updates the font
              /// </summary>
              private void UpdateFont()

              Control.Typeface = Element.Font.ToExtendedTypeface(Context);


              /// <summary>
              /// Sets the alignment.
              /// </summary>
              private void UpdateAlignment()

              element.HorizontalContentAlignment.ToDroidHorizontalGravity();




              iOS Renderer:



               public class ExtendedButtonRenderer : ButtonRenderer

              /// <summary>
              /// Called when [element changed].
              /// </summary>
              /// <param name="e">The e.</param>
              protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
              this.Control == null)

              return;


              this.Control.VerticalAlignment = this.Element.VerticalContentAlignment.ToContentVerticalAlignment();
              this.Control.HorizontalAlignment = this.Element.HorizontalContentAlignment.ToContentHorizontalAlignment();


              /// <summary>
              /// Handles the <see cref="E:ElementPropertyChanged" /> event.
              /// </summary>
              /// <param name="sender">The sender.</param>
              /// <param name="e">The <see cref="PropertyChangedEventArgs"/> instance containing the event data.</param>
              protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)

              switch (e.PropertyName)

              case "VerticalContentAlignment":
              this.Control.VerticalAlignment = this.Element.VerticalContentAlignment.ToContentVerticalAlignment();
              break;
              case "HorizontalContentAlignment":
              this.Control.HorizontalAlignment = this.Element.HorizontalContentAlignment.ToContentHorizontalAlignment();
              break;
              default:
              base.OnElementPropertyChanged(sender, e);
              break;



              /// <summary>
              /// Gets the element.
              /// </summary>
              /// <value>The element.</value>
              public new ExtendedButton Element

              get

              return base.Element as ExtendedButton;





              Do not forget to add the ExportRenderer Attribute on both renderers [assembly: ExportRenderer(typeof(ExtendedButton), typeof(ExtendedButtonRenderer))]



              Goodluck feel free to revert in case of queries






              share|improve this answer































                2















                What you are looking for is something like in this XLab Control



                 public class ExtendedButton : Button

                /// <summary>
                /// Bindable property for button content vertical alignment.
                /// </summary>
                public static readonly BindableProperty VerticalContentAlignmentProperty =
                BindableProperty.Create<ExtendedButton, TextAlignment>(
                p => p.VerticalContentAlignment, TextAlignment.Center);

                /// <summary>
                /// Bindable property for button content horizontal alignment.
                /// </summary>
                public static readonly BindableProperty HorizontalContentAlignmentProperty =
                BindableProperty.Create<ExtendedButton, TextAlignment>(
                p => p.HorizontalContentAlignment, TextAlignment.Center);

                /// <summary>
                /// Gets or sets the content vertical alignment.
                /// </summary>
                public TextAlignment VerticalContentAlignment

                get return this.GetValue<TextAlignment>(VerticalContentAlignmentProperty);
                set this.SetValue(VerticalContentAlignmentProperty, value);


                /// <summary>
                /// Gets or sets the content horizontal alignment.
                /// </summary>
                public TextAlignment HorizontalContentAlignment

                get return this.GetValue<TextAlignment>(HorizontalContentAlignmentProperty);
                set this.SetValue(HorizontalContentAlignmentProperty, value);




                Android renderer:



                public class ExtendedButtonRenderer : ButtonRenderer

                /// <summary>
                /// Called when [element changed].
                /// </summary>
                /// <param name="e">The e.</param>
                protected override void OnElementChanged(ElementChangedEventArgs<Button> e)

                base.OnElementChanged(e);
                UpdateAlignment();
                UpdateFont();


                /// <summary>
                /// Handles the <see cref="E:ElementPropertyChanged" /> event.
                /// </summary>
                /// <param name="sender">The sender.</param>
                /// <param name="e">The <see cref="PropertyChangedEventArgs"/> instance containing the event data.</param>
                protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)


                /// <summary>
                /// Updates the font
                /// </summary>
                private void UpdateFont()

                Control.Typeface = Element.Font.ToExtendedTypeface(Context);


                /// <summary>
                /// Sets the alignment.
                /// </summary>
                private void UpdateAlignment()

                element.HorizontalContentAlignment.ToDroidHorizontalGravity();




                iOS Renderer:



                 public class ExtendedButtonRenderer : ButtonRenderer

                /// <summary>
                /// Called when [element changed].
                /// </summary>
                /// <param name="e">The e.</param>
                protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
                this.Control == null)

                return;


                this.Control.VerticalAlignment = this.Element.VerticalContentAlignment.ToContentVerticalAlignment();
                this.Control.HorizontalAlignment = this.Element.HorizontalContentAlignment.ToContentHorizontalAlignment();


                /// <summary>
                /// Handles the <see cref="E:ElementPropertyChanged" /> event.
                /// </summary>
                /// <param name="sender">The sender.</param>
                /// <param name="e">The <see cref="PropertyChangedEventArgs"/> instance containing the event data.</param>
                protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)

                switch (e.PropertyName)

                case "VerticalContentAlignment":
                this.Control.VerticalAlignment = this.Element.VerticalContentAlignment.ToContentVerticalAlignment();
                break;
                case "HorizontalContentAlignment":
                this.Control.HorizontalAlignment = this.Element.HorizontalContentAlignment.ToContentHorizontalAlignment();
                break;
                default:
                base.OnElementPropertyChanged(sender, e);
                break;



                /// <summary>
                /// Gets the element.
                /// </summary>
                /// <value>The element.</value>
                public new ExtendedButton Element

                get

                return base.Element as ExtendedButton;





                Do not forget to add the ExportRenderer Attribute on both renderers [assembly: ExportRenderer(typeof(ExtendedButton), typeof(ExtendedButtonRenderer))]



                Goodluck feel free to revert in case of queries






                share|improve this answer





























                  2














                  2










                  2









                  What you are looking for is something like in this XLab Control



                   public class ExtendedButton : Button

                  /// <summary>
                  /// Bindable property for button content vertical alignment.
                  /// </summary>
                  public static readonly BindableProperty VerticalContentAlignmentProperty =
                  BindableProperty.Create<ExtendedButton, TextAlignment>(
                  p => p.VerticalContentAlignment, TextAlignment.Center);

                  /// <summary>
                  /// Bindable property for button content horizontal alignment.
                  /// </summary>
                  public static readonly BindableProperty HorizontalContentAlignmentProperty =
                  BindableProperty.Create<ExtendedButton, TextAlignment>(
                  p => p.HorizontalContentAlignment, TextAlignment.Center);

                  /// <summary>
                  /// Gets or sets the content vertical alignment.
                  /// </summary>
                  public TextAlignment VerticalContentAlignment

                  get return this.GetValue<TextAlignment>(VerticalContentAlignmentProperty);
                  set this.SetValue(VerticalContentAlignmentProperty, value);


                  /// <summary>
                  /// Gets or sets the content horizontal alignment.
                  /// </summary>
                  public TextAlignment HorizontalContentAlignment

                  get return this.GetValue<TextAlignment>(HorizontalContentAlignmentProperty);
                  set this.SetValue(HorizontalContentAlignmentProperty, value);




                  Android renderer:



                  public class ExtendedButtonRenderer : ButtonRenderer

                  /// <summary>
                  /// Called when [element changed].
                  /// </summary>
                  /// <param name="e">The e.</param>
                  protected override void OnElementChanged(ElementChangedEventArgs<Button> e)

                  base.OnElementChanged(e);
                  UpdateAlignment();
                  UpdateFont();


                  /// <summary>
                  /// Handles the <see cref="E:ElementPropertyChanged" /> event.
                  /// </summary>
                  /// <param name="sender">The sender.</param>
                  /// <param name="e">The <see cref="PropertyChangedEventArgs"/> instance containing the event data.</param>
                  protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)


                  /// <summary>
                  /// Updates the font
                  /// </summary>
                  private void UpdateFont()

                  Control.Typeface = Element.Font.ToExtendedTypeface(Context);


                  /// <summary>
                  /// Sets the alignment.
                  /// </summary>
                  private void UpdateAlignment()

                  element.HorizontalContentAlignment.ToDroidHorizontalGravity();




                  iOS Renderer:



                   public class ExtendedButtonRenderer : ButtonRenderer

                  /// <summary>
                  /// Called when [element changed].
                  /// </summary>
                  /// <param name="e">The e.</param>
                  protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
                  this.Control == null)

                  return;


                  this.Control.VerticalAlignment = this.Element.VerticalContentAlignment.ToContentVerticalAlignment();
                  this.Control.HorizontalAlignment = this.Element.HorizontalContentAlignment.ToContentHorizontalAlignment();


                  /// <summary>
                  /// Handles the <see cref="E:ElementPropertyChanged" /> event.
                  /// </summary>
                  /// <param name="sender">The sender.</param>
                  /// <param name="e">The <see cref="PropertyChangedEventArgs"/> instance containing the event data.</param>
                  protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)

                  switch (e.PropertyName)

                  case "VerticalContentAlignment":
                  this.Control.VerticalAlignment = this.Element.VerticalContentAlignment.ToContentVerticalAlignment();
                  break;
                  case "HorizontalContentAlignment":
                  this.Control.HorizontalAlignment = this.Element.HorizontalContentAlignment.ToContentHorizontalAlignment();
                  break;
                  default:
                  base.OnElementPropertyChanged(sender, e);
                  break;



                  /// <summary>
                  /// Gets the element.
                  /// </summary>
                  /// <value>The element.</value>
                  public new ExtendedButton Element

                  get

                  return base.Element as ExtendedButton;





                  Do not forget to add the ExportRenderer Attribute on both renderers [assembly: ExportRenderer(typeof(ExtendedButton), typeof(ExtendedButtonRenderer))]



                  Goodluck feel free to revert in case of queries






                  share|improve this answer















                  What you are looking for is something like in this XLab Control



                   public class ExtendedButton : Button

                  /// <summary>
                  /// Bindable property for button content vertical alignment.
                  /// </summary>
                  public static readonly BindableProperty VerticalContentAlignmentProperty =
                  BindableProperty.Create<ExtendedButton, TextAlignment>(
                  p => p.VerticalContentAlignment, TextAlignment.Center);

                  /// <summary>
                  /// Bindable property for button content horizontal alignment.
                  /// </summary>
                  public static readonly BindableProperty HorizontalContentAlignmentProperty =
                  BindableProperty.Create<ExtendedButton, TextAlignment>(
                  p => p.HorizontalContentAlignment, TextAlignment.Center);

                  /// <summary>
                  /// Gets or sets the content vertical alignment.
                  /// </summary>
                  public TextAlignment VerticalContentAlignment

                  get return this.GetValue<TextAlignment>(VerticalContentAlignmentProperty);
                  set this.SetValue(VerticalContentAlignmentProperty, value);


                  /// <summary>
                  /// Gets or sets the content horizontal alignment.
                  /// </summary>
                  public TextAlignment HorizontalContentAlignment

                  get return this.GetValue<TextAlignment>(HorizontalContentAlignmentProperty);
                  set this.SetValue(HorizontalContentAlignmentProperty, value);




                  Android renderer:



                  public class ExtendedButtonRenderer : ButtonRenderer

                  /// <summary>
                  /// Called when [element changed].
                  /// </summary>
                  /// <param name="e">The e.</param>
                  protected override void OnElementChanged(ElementChangedEventArgs<Button> e)

                  base.OnElementChanged(e);
                  UpdateAlignment();
                  UpdateFont();


                  /// <summary>
                  /// Handles the <see cref="E:ElementPropertyChanged" /> event.
                  /// </summary>
                  /// <param name="sender">The sender.</param>
                  /// <param name="e">The <see cref="PropertyChangedEventArgs"/> instance containing the event data.</param>
                  protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)


                  /// <summary>
                  /// Updates the font
                  /// </summary>
                  private void UpdateFont()

                  Control.Typeface = Element.Font.ToExtendedTypeface(Context);


                  /// <summary>
                  /// Sets the alignment.
                  /// </summary>
                  private void UpdateAlignment()

                  element.HorizontalContentAlignment.ToDroidHorizontalGravity();




                  iOS Renderer:



                   public class ExtendedButtonRenderer : ButtonRenderer

                  /// <summary>
                  /// Called when [element changed].
                  /// </summary>
                  /// <param name="e">The e.</param>
                  protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
                  this.Control == null)

                  return;


                  this.Control.VerticalAlignment = this.Element.VerticalContentAlignment.ToContentVerticalAlignment();
                  this.Control.HorizontalAlignment = this.Element.HorizontalContentAlignment.ToContentHorizontalAlignment();


                  /// <summary>
                  /// Handles the <see cref="E:ElementPropertyChanged" /> event.
                  /// </summary>
                  /// <param name="sender">The sender.</param>
                  /// <param name="e">The <see cref="PropertyChangedEventArgs"/> instance containing the event data.</param>
                  protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)

                  switch (e.PropertyName)

                  case "VerticalContentAlignment":
                  this.Control.VerticalAlignment = this.Element.VerticalContentAlignment.ToContentVerticalAlignment();
                  break;
                  case "HorizontalContentAlignment":
                  this.Control.HorizontalAlignment = this.Element.HorizontalContentAlignment.ToContentHorizontalAlignment();
                  break;
                  default:
                  base.OnElementPropertyChanged(sender, e);
                  break;



                  /// <summary>
                  /// Gets the element.
                  /// </summary>
                  /// <value>The element.</value>
                  public new ExtendedButton Element

                  get

                  return base.Element as ExtendedButton;





                  Do not forget to add the ExportRenderer Attribute on both renderers [assembly: ExportRenderer(typeof(ExtendedButton), typeof(ExtendedButtonRenderer))]



                  Goodluck feel free to revert in case of queries







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 27 at 18:29

























                  answered Mar 27 at 18:12









                  G.hakimG.hakim

                  6,3702 gold badges12 silver badges37 bronze badges




                  6,3702 gold badges12 silver badges37 bronze badges


























                      0















                      You need to create a custom renderer for the button then in the customization of the control, call:



                      button.Gravity = GravityFlags.Left;


                      You will see your texts aligned to the left.






                      share|improve this answer





























                        0















                        You need to create a custom renderer for the button then in the customization of the control, call:



                        button.Gravity = GravityFlags.Left;


                        You will see your texts aligned to the left.






                        share|improve this answer



























                          0














                          0










                          0









                          You need to create a custom renderer for the button then in the customization of the control, call:



                          button.Gravity = GravityFlags.Left;


                          You will see your texts aligned to the left.






                          share|improve this answer













                          You need to create a custom renderer for the button then in the customization of the control, call:



                          button.Gravity = GravityFlags.Left;


                          You will see your texts aligned to the left.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 27 at 18:49









                          SergioAMGSergioAMG

                          3411 silver badge10 bronze badges




                          3411 silver badge10 bronze badges






























                              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%2f55382294%2fhow-to-change-text-alignment-of-button-on-android-xamarin-forms%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

                              Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                              SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                              은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현