The Image is not in the center on Button when displaying with a text.
The image have to stick the text on the center.
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);
}
OnElementPropertChanged only fires when you change a property on an Element after it has been rendered on the screen. When are you setting the Image property? If you're setting it in the constructor, that will be handled by OnElementChanged. If you still need assistance with this issue, please reopen it and attach a small reproduction project. Thank you!
First thanks for your time,
Forget about the PropertyChanged (my bad, I was expected ImageProperty not TextProperty in sample)
The issue is about the image stick close to the border, depending of Button.ContentLayout.Position
Android:

expected like on iOS:

The image is not centered and it's caused by:
-> Here an implementation in Java of a Custom drawn Android button which aligns left drawable and its text to center.
Regards,
X:\git\forms\Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Bugzilla27417.cs
Does anyone have a workaround?
Does anyone have a workaround?
You could use the option of 'padding' on the button itself as a work around?
Does anyone have a workaround?
You could use the option of 'padding' on the button itself as a work around?
Yep, that's what I've ended up with (I'm lucky to have a fixed width buttons in this project). Thanks
So, I have fixed this for Material, and encapsulated all the logic for button layout into a single place: https://github.com/xamarin/Xamarin.Forms/pull/4967
Right now, all that is needed to get the image in either place is a boolean flag. However, as this is a breaking change for the older renderers, we will probably not be able to change the behaviour.
However, there are some things we can do: