2016-03-23 02:16:53 +03:00
|
|
|
using Xamarin.Forms.CustomAttributes;
|
2016-04-26 18:20:55 +03:00
|
|
|
using Xamarin.Forms.Internals;
|
2016-03-23 02:16:53 +03:00
|
|
|
|
|
|
|
namespace Xamarin.Forms.Controls.Issues
|
|
|
|
{
|
|
|
|
[Preserve(AllMembers = true)]
|
|
|
|
[Issue(IssueTracker.Bugzilla, 27417,
|
|
|
|
"Button.Image behaviors differently on each platform and has extra padding even with no Text", PlatformAffected.All)]
|
|
|
|
public class Bugzilla27417 : TestContentPage
|
|
|
|
{
|
|
|
|
protected override void Init()
|
|
|
|
{
|
2016-06-16 19:35:24 +03:00
|
|
|
var instructions = new Label { Text = @"There should be 8 buttons below (the bottom 7 are in a ScrollView).
|
|
|
|
Buttons 1 and 2 have images which are horizontally and vertically centered.
|
|
|
|
Button 3 should have the text 'Click Me' in the center.
|
|
|
|
Button 4 should have an image in the center and no text.
|
|
|
|
Button 5 should have the image on the left and the text on the right.
|
|
|
|
Button 6 should have the image on the top and the text on the bottom.
|
|
|
|
Button 7 should have the image on the bottom and the text on the top.
|
|
|
|
Button 8 have the image on the right and the text on the left." };
|
|
|
|
|
|
|
|
var grid = new Grid
|
|
|
|
{
|
|
|
|
RowDefinitions = new RowDefinitionCollection
|
|
|
|
{
|
|
|
|
new RowDefinition { Height = 100 }
|
|
|
|
},
|
|
|
|
VerticalOptions = LayoutOptions.Start,
|
|
|
|
Children =
|
|
|
|
{
|
|
|
|
new Button
|
|
|
|
{
|
|
|
|
HeightRequest = 500, // Making sure that the image still gets centered vertically even if the HeightRequest won't be honored
|
2019-04-26 23:46:13 +03:00
|
|
|
ImageSource = "coffee.png"
|
2016-06-16 19:35:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2016-03-23 02:16:53 +03:00
|
|
|
|
|
|
|
Content = new StackLayout
|
|
|
|
{
|
2016-06-16 19:35:24 +03:00
|
|
|
VerticalOptions = LayoutOptions.Fill,
|
2016-03-23 02:16:53 +03:00
|
|
|
Spacing = 10,
|
|
|
|
Children =
|
|
|
|
{
|
|
|
|
instructions,
|
2016-06-16 19:35:24 +03:00
|
|
|
grid,
|
2016-03-23 02:16:53 +03:00
|
|
|
new ScrollView
|
|
|
|
{
|
|
|
|
Content = new StackLayout
|
|
|
|
{
|
|
|
|
Spacing = 10,
|
|
|
|
VerticalOptions = LayoutOptions.Center,
|
|
|
|
HorizontalOptions = LayoutOptions.Center,
|
|
|
|
Children =
|
|
|
|
{
|
2019-04-26 23:46:13 +03:00
|
|
|
new Button { WidthRequest = 200, HeightRequest = 300, ImageSource = "coffee.png" },
|
2016-03-23 02:16:53 +03:00
|
|
|
new Button { Text = "Click Me", BackgroundColor = Color.Gray },
|
2019-04-26 23:46:13 +03:00
|
|
|
new Button { ImageSource = "coffee.png", BackgroundColor = Color.Gray },
|
2016-03-23 02:16:53 +03:00
|
|
|
CreateButton(new Button.ButtonContentLayout(Button.ButtonContentLayout.ImagePosition.Left, 10)),
|
|
|
|
CreateButton(new Button.ButtonContentLayout(Button.ButtonContentLayout.ImagePosition.Top, 10)),
|
|
|
|
CreateButton(new Button.ButtonContentLayout(Button.ButtonContentLayout.ImagePosition.Bottom, 10)),
|
|
|
|
CreateButton(new Button.ButtonContentLayout(Button.ButtonContentLayout.ImagePosition.Right, 10))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
static Button CreateButton(Button.ButtonContentLayout layout)
|
|
|
|
{
|
|
|
|
return new Button
|
|
|
|
{
|
|
|
|
Text = "Click Me",
|
2019-04-26 23:46:13 +03:00
|
|
|
ImageSource = "coffee.png",
|
2016-03-23 02:16:53 +03:00
|
|
|
ContentLayout = layout,
|
|
|
|
BackgroundColor = Color.Gray
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|