xamarin/Xamarin.Forms

[Android] Image on Button is not centered with text

Open

#3,527 opened on Aug 9, 2018

 (15 comments) (4 reactions) (0 assignees)C# (1,926 forks)batch import
a/buttone/3 :clock3:help wantedinactivep/Androidt/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Description

The Image is not in the center on Button when displaying with a text.

Steps to Reproduce

  1. Create a Button with an image & text.
  2. Set thee HorizontalOption to Fill&Expand.
  3. You can see that the image is stick to the left border
  4. If you change the position(Top,Right...) of the image it will stick on the position selected, not centered with the text

Expected Behavior

The image have to stick the text on the center.

Actual Behavior

The Image is stick to the border depends of the selected position. I was searching a way to make a correction on UpdateBitmap But PropertyName "Image" never pass to UpdateBitmap

        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == Button.TextProperty.PropertyName)
                UpdateBitmap();

            base.OnElementPropertyChanged(sender, e);
        }

Basic Information

  • Xamarin.Forms: 3.1.0.697729
    • Android: 8.1

Contributor guide