Hello,
I am not sure why the button change text alignment after button clicked if the button is in a grid and there is a label and grid in StackLayout for android.
Here is a test case of the source code.
using Xamarin.Forms;
namespace ButtonTextAlignment
{
public class ContentPageGrid : ContentPage
{
public ContentPageGrid()
{
var layout = new StackLayout
{
Orientation = StackOrientation.Vertical,
Padding = 20
};
var labelUsDollor = new Label
{
Text = "label",
TextColor = Color.White,
BackgroundColor = Color.Blue
};
layout.Children.Add(labelUsDollor);
var grid = new Grid
{
RowSpacing = 10
};
var button = new Button
{
Text = "Click me to test",
TextColor = Color.White,
BackgroundColor = Color.Blue,
WidthRequest = 400
};
button.Clicked += (sender, e) =>
{
labelUsDollor.Text = "button text change alignment";
};
grid.Children.Add(button, 0, 0);
layout.Children.Add(grid);
Content = layout;
}
}
}
Regards
Leigh