Xamarin Forms ProgressBar Height is not controllable





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







0















We have upgraded from Xamarin Forms 2.5 to 3.4.
The ProgressBar on Android becomes thicker and not controllable by XAML's HeightRequest, while it was before.



It is within a grid layout.



Any ideas how to control the height?










share|improve this question































    0















    We have upgraded from Xamarin Forms 2.5 to 3.4.
    The ProgressBar on Android becomes thicker and not controllable by XAML's HeightRequest, while it was before.



    It is within a grid layout.



    Any ideas how to control the height?










    share|improve this question



























      0












      0








      0








      We have upgraded from Xamarin Forms 2.5 to 3.4.
      The ProgressBar on Android becomes thicker and not controllable by XAML's HeightRequest, while it was before.



      It is within a grid layout.



      Any ideas how to control the height?










      share|improve this question
















      We have upgraded from Xamarin Forms 2.5 to 3.4.
      The ProgressBar on Android becomes thicker and not controllable by XAML's HeightRequest, while it was before.



      It is within a grid layout.



      Any ideas how to control the height?







      xamarin xamarin.forms android-progressbar






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 '18 at 11:22









      Arvindraja

      2,94531132




      2,94531132










      asked Nov 22 '18 at 11:16









      AdamAdam

      1,46911940




      1,46911940
























          2 Answers
          2






          active

          oldest

          votes


















          0














          You can modify the height of the progressbar by using Render in xamarin.



          CustomProgressBarRenderer.cs



          using Android.OS;
          using Android.Runtime;
          using Android.Views;
          using Android.Widget;
          using Xamarin.Forms;
          using Xamarin.Forms.Platform.Android;

          [assembly: ExportRenderer(typeof(App69.CustomProgressBar), typeof(App69.Droid.CustomProgressBarRenderer))]
          namespace App69.Droid
          {
          public class CustomProgressBarRenderer : ProgressBarRenderer
          {
          public CustomProgressBarRenderer(Context context) : base(context) { }
          protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
          {
          base.OnElementChanged(e);
          if (Control != null)
          {
          Control.ScaleY = 10; //Changes the height
          }
          }
          }
          }


          MainPage.xaml



          <?xml version="1.0" encoding="utf-8" ?>
          <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
          xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
          xmlns:local="clr-namespace:App69"
          x:Class="App69.MainPage">

          <Grid>
          <Grid.RowDefinitions>
          <RowDefinition Height="*" />
          <RowDefinition Height="*" />
          </Grid.RowDefinitions>
          <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="*" />
          </Grid.ColumnDefinitions>
          <Label Text="Top Left" Grid.Row="0" Grid.Column="0" />
          <Label Text="Top Right" Grid.Row="0" Grid.Column="1" />
          <Label Text="Bottom Left" Grid.Row="0" Grid.Column="1" />
          <local:CustomProgressBar Progress="0.5" Grid.Row="1" Grid.Column="1" />
          </Grid>

          </ContentPage>





          share|improve this answer































            0














             class CustomProgressBarRenderer : ProgressBarRenderer
            {
            /// <summary>
            /// Raises the <see cref="E:ElementChanged" /> event.
            /// </summary>
            /// <param name="e">The <see cref="ElementChangedEventArgs{Xamarin.Forms.ProgressBar}"/> instance containing the event data.</param>
            protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
            {
            base.OnElementChanged(e);
            var element = Element as CustomProgressBar;
            Control.IndeterminateDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
            Control.ProgressDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
            Control.ScaleY = element.BarHeight;
            }

            /// <summary>
            /// Called when [element property changed].
            /// </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)
            {
            base.OnElementPropertyChanged(sender, e);
            var element = Element as CustomProgressBar;
            Control.IndeterminateDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
            Control.ProgressDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
            Control.ScaleY = element.BarHeight;
            }
            }





            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%2f53429761%2fxamarin-forms-progressbar-height-is-not-controllable%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









              0














              You can modify the height of the progressbar by using Render in xamarin.



              CustomProgressBarRenderer.cs



              using Android.OS;
              using Android.Runtime;
              using Android.Views;
              using Android.Widget;
              using Xamarin.Forms;
              using Xamarin.Forms.Platform.Android;

              [assembly: ExportRenderer(typeof(App69.CustomProgressBar), typeof(App69.Droid.CustomProgressBarRenderer))]
              namespace App69.Droid
              {
              public class CustomProgressBarRenderer : ProgressBarRenderer
              {
              public CustomProgressBarRenderer(Context context) : base(context) { }
              protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
              {
              base.OnElementChanged(e);
              if (Control != null)
              {
              Control.ScaleY = 10; //Changes the height
              }
              }
              }
              }


              MainPage.xaml



              <?xml version="1.0" encoding="utf-8" ?>
              <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              xmlns:local="clr-namespace:App69"
              x:Class="App69.MainPage">

              <Grid>
              <Grid.RowDefinitions>
              <RowDefinition Height="*" />
              <RowDefinition Height="*" />
              </Grid.RowDefinitions>
              <Grid.ColumnDefinitions>
              <ColumnDefinition Width="*" />
              <ColumnDefinition Width="*" />
              </Grid.ColumnDefinitions>
              <Label Text="Top Left" Grid.Row="0" Grid.Column="0" />
              <Label Text="Top Right" Grid.Row="0" Grid.Column="1" />
              <Label Text="Bottom Left" Grid.Row="0" Grid.Column="1" />
              <local:CustomProgressBar Progress="0.5" Grid.Row="1" Grid.Column="1" />
              </Grid>

              </ContentPage>





              share|improve this answer




























                0














                You can modify the height of the progressbar by using Render in xamarin.



                CustomProgressBarRenderer.cs



                using Android.OS;
                using Android.Runtime;
                using Android.Views;
                using Android.Widget;
                using Xamarin.Forms;
                using Xamarin.Forms.Platform.Android;

                [assembly: ExportRenderer(typeof(App69.CustomProgressBar), typeof(App69.Droid.CustomProgressBarRenderer))]
                namespace App69.Droid
                {
                public class CustomProgressBarRenderer : ProgressBarRenderer
                {
                public CustomProgressBarRenderer(Context context) : base(context) { }
                protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
                {
                base.OnElementChanged(e);
                if (Control != null)
                {
                Control.ScaleY = 10; //Changes the height
                }
                }
                }
                }


                MainPage.xaml



                <?xml version="1.0" encoding="utf-8" ?>
                <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                xmlns:local="clr-namespace:App69"
                x:Class="App69.MainPage">

                <Grid>
                <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Label Text="Top Left" Grid.Row="0" Grid.Column="0" />
                <Label Text="Top Right" Grid.Row="0" Grid.Column="1" />
                <Label Text="Bottom Left" Grid.Row="0" Grid.Column="1" />
                <local:CustomProgressBar Progress="0.5" Grid.Row="1" Grid.Column="1" />
                </Grid>

                </ContentPage>





                share|improve this answer


























                  0












                  0








                  0







                  You can modify the height of the progressbar by using Render in xamarin.



                  CustomProgressBarRenderer.cs



                  using Android.OS;
                  using Android.Runtime;
                  using Android.Views;
                  using Android.Widget;
                  using Xamarin.Forms;
                  using Xamarin.Forms.Platform.Android;

                  [assembly: ExportRenderer(typeof(App69.CustomProgressBar), typeof(App69.Droid.CustomProgressBarRenderer))]
                  namespace App69.Droid
                  {
                  public class CustomProgressBarRenderer : ProgressBarRenderer
                  {
                  public CustomProgressBarRenderer(Context context) : base(context) { }
                  protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
                  {
                  base.OnElementChanged(e);
                  if (Control != null)
                  {
                  Control.ScaleY = 10; //Changes the height
                  }
                  }
                  }
                  }


                  MainPage.xaml



                  <?xml version="1.0" encoding="utf-8" ?>
                  <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                  xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                  xmlns:local="clr-namespace:App69"
                  x:Class="App69.MainPage">

                  <Grid>
                  <Grid.RowDefinitions>
                  <RowDefinition Height="*" />
                  <RowDefinition Height="*" />
                  </Grid.RowDefinitions>
                  <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="*" />
                  <ColumnDefinition Width="*" />
                  </Grid.ColumnDefinitions>
                  <Label Text="Top Left" Grid.Row="0" Grid.Column="0" />
                  <Label Text="Top Right" Grid.Row="0" Grid.Column="1" />
                  <Label Text="Bottom Left" Grid.Row="0" Grid.Column="1" />
                  <local:CustomProgressBar Progress="0.5" Grid.Row="1" Grid.Column="1" />
                  </Grid>

                  </ContentPage>





                  share|improve this answer













                  You can modify the height of the progressbar by using Render in xamarin.



                  CustomProgressBarRenderer.cs



                  using Android.OS;
                  using Android.Runtime;
                  using Android.Views;
                  using Android.Widget;
                  using Xamarin.Forms;
                  using Xamarin.Forms.Platform.Android;

                  [assembly: ExportRenderer(typeof(App69.CustomProgressBar), typeof(App69.Droid.CustomProgressBarRenderer))]
                  namespace App69.Droid
                  {
                  public class CustomProgressBarRenderer : ProgressBarRenderer
                  {
                  public CustomProgressBarRenderer(Context context) : base(context) { }
                  protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
                  {
                  base.OnElementChanged(e);
                  if (Control != null)
                  {
                  Control.ScaleY = 10; //Changes the height
                  }
                  }
                  }
                  }


                  MainPage.xaml



                  <?xml version="1.0" encoding="utf-8" ?>
                  <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                  xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                  xmlns:local="clr-namespace:App69"
                  x:Class="App69.MainPage">

                  <Grid>
                  <Grid.RowDefinitions>
                  <RowDefinition Height="*" />
                  <RowDefinition Height="*" />
                  </Grid.RowDefinitions>
                  <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="*" />
                  <ColumnDefinition Width="*" />
                  </Grid.ColumnDefinitions>
                  <Label Text="Top Left" Grid.Row="0" Grid.Column="0" />
                  <Label Text="Top Right" Grid.Row="0" Grid.Column="1" />
                  <Label Text="Bottom Left" Grid.Row="0" Grid.Column="1" />
                  <local:CustomProgressBar Progress="0.5" Grid.Row="1" Grid.Column="1" />
                  </Grid>

                  </ContentPage>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 26 '18 at 3:38









                  AbbyWang - MSFTAbbyWang - MSFT

                  58916




                  58916

























                      0














                       class CustomProgressBarRenderer : ProgressBarRenderer
                      {
                      /// <summary>
                      /// Raises the <see cref="E:ElementChanged" /> event.
                      /// </summary>
                      /// <param name="e">The <see cref="ElementChangedEventArgs{Xamarin.Forms.ProgressBar}"/> instance containing the event data.</param>
                      protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
                      {
                      base.OnElementChanged(e);
                      var element = Element as CustomProgressBar;
                      Control.IndeterminateDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
                      Control.ProgressDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
                      Control.ScaleY = element.BarHeight;
                      }

                      /// <summary>
                      /// Called when [element property changed].
                      /// </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)
                      {
                      base.OnElementPropertyChanged(sender, e);
                      var element = Element as CustomProgressBar;
                      Control.IndeterminateDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
                      Control.ProgressDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
                      Control.ScaleY = element.BarHeight;
                      }
                      }





                      share|improve this answer




























                        0














                         class CustomProgressBarRenderer : ProgressBarRenderer
                        {
                        /// <summary>
                        /// Raises the <see cref="E:ElementChanged" /> event.
                        /// </summary>
                        /// <param name="e">The <see cref="ElementChangedEventArgs{Xamarin.Forms.ProgressBar}"/> instance containing the event data.</param>
                        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
                        {
                        base.OnElementChanged(e);
                        var element = Element as CustomProgressBar;
                        Control.IndeterminateDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
                        Control.ProgressDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
                        Control.ScaleY = element.BarHeight;
                        }

                        /// <summary>
                        /// Called when [element property changed].
                        /// </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)
                        {
                        base.OnElementPropertyChanged(sender, e);
                        var element = Element as CustomProgressBar;
                        Control.IndeterminateDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
                        Control.ProgressDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
                        Control.ScaleY = element.BarHeight;
                        }
                        }





                        share|improve this answer


























                          0












                          0








                          0







                           class CustomProgressBarRenderer : ProgressBarRenderer
                          {
                          /// <summary>
                          /// Raises the <see cref="E:ElementChanged" /> event.
                          /// </summary>
                          /// <param name="e">The <see cref="ElementChangedEventArgs{Xamarin.Forms.ProgressBar}"/> instance containing the event data.</param>
                          protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
                          {
                          base.OnElementChanged(e);
                          var element = Element as CustomProgressBar;
                          Control.IndeterminateDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
                          Control.ProgressDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
                          Control.ScaleY = element.BarHeight;
                          }

                          /// <summary>
                          /// Called when [element property changed].
                          /// </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)
                          {
                          base.OnElementPropertyChanged(sender, e);
                          var element = Element as CustomProgressBar;
                          Control.IndeterminateDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
                          Control.ProgressDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
                          Control.ScaleY = element.BarHeight;
                          }
                          }





                          share|improve this answer













                           class CustomProgressBarRenderer : ProgressBarRenderer
                          {
                          /// <summary>
                          /// Raises the <see cref="E:ElementChanged" /> event.
                          /// </summary>
                          /// <param name="e">The <see cref="ElementChangedEventArgs{Xamarin.Forms.ProgressBar}"/> instance containing the event data.</param>
                          protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ProgressBar> e)
                          {
                          base.OnElementChanged(e);
                          var element = Element as CustomProgressBar;
                          Control.IndeterminateDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
                          Control.ProgressDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
                          Control.ScaleY = element.BarHeight;
                          }

                          /// <summary>
                          /// Called when [element property changed].
                          /// </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)
                          {
                          base.OnElementPropertyChanged(sender, e);
                          var element = Element as CustomProgressBar;
                          Control.IndeterminateDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
                          Control.ProgressDrawable.SetColorFilter(element.BarColor.ToAndroid(), PorterDuff.Mode.SrcIn);
                          Control.ScaleY = element.BarHeight;
                          }
                          }






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Dec 3 '18 at 9:34









                          Chetan RawatChetan Rawat

                          83




                          83






























                              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%2f53429761%2fxamarin-forms-progressbar-height-is-not-controllable%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

                              mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

                              How to change which sound is reproduced for terminal bell?

                              Can I use Tabulator js library in my java Spring + Thymeleaf project?