Has anything changed with the RelativeLayout
between 1.3.1 stable and this release? I ask because after updating, my text labels have disappeared.
I've attached two screenshots, my code is below.
public class TaskTileTemplate : ContentView
{
private readonly Constraint _centerX = Constraint.RelativeToParent(parent => parent.Width / 2);
private readonly Constraint _centerY = Constraint.RelativeToParent(parent => parent.Height / 2);
public TaskTileTemplate(object item)
{
BindingContext = item;
var innerLayout = new RelativeLayout { WidthRequest = int.MaxValue, HeightRequest = int.MaxValue };
var refLabel = new Label { FontSize = 20, Opacity = 0 };
var lbl = new Label { FontSize = 20 , TextColor = Color.White};
var refActivityIndicator = new ActivityIndicator { IsRunning = false, IsVisible = false };
var activityIndicator = new ActivityIndicator { IsRunning = false, IsVisible = false };
// reference label exists becase we don't know the length of 'Name'
refLabel.SetBinding(Label.TextProperty, "Name");
lbl.SetBinding(Label.TextProperty, "Name");
lbl.SetBinding(Label.TextColorProperty, "Color", BindingMode.OneWay, new BrightnessInversionConverter());
activityIndicator.SetBinding(IsVisibleProperty, "IsBusy");
activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");
innerLayout.Children.Add(refLabel, _centerX, _centerY);
innerLayout.Children.Add(lbl,
Constraint.RelativeToView(refLabel, (parent, sibling) => sibling.X - sibling.Width / 2), // X
Constraint.RelativeToView(refLabel, (parent, sibling) => sibling.Y - sibling.Height / 2)); //Y
innerLayout.Children.Add(refActivityIndicator, _centerX, _centerY);
innerLayout.Children.Add(activityIndicator,
Constraint.RelativeToView(refActivityIndicator, (parent, sibling) => sibling.X - sibling.Width / 2), // X
Constraint.RelativeToView(refActivityIndicator, (parent, sibling) => sibling.Y - sibling.Height / 2)); //Y
var tile = new ExtendedContentView
{
Content = innerLayout,
VerticalOptions = LayoutOptions.FillAndExpand,
};
tile.SetBinding(BackgroundColorProperty, "Color", BindingMode.OneWay, new HexToColorConverter());
IsClippedToBounds = false;
Content = tile;
}
}
I am pretty sure I can get around this issue with a simple StackLayout and centered text, but eventually I plan on adding fontawesome icons and such to this view, so I sort of need it to be relative.