Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

[UWP] Fix ActivityIndicator width in absolutelayout#3224

Merged
PureWeen merged 5 commits intoxamarin:masterfrom
paymicro:fix-gh1399-absolute-layout
Oct 30, 2018
Merged

[UWP] Fix ActivityIndicator width in absolutelayout#3224
PureWeen merged 5 commits intoxamarin:masterfrom
paymicro:fix-gh1399-absolute-layout

Conversation

@paymicro
Copy link
Copy Markdown
Contributor

@paymicro paymicro commented Jul 5, 2018

Description of Change

ActivityIndicator in UWP occupies all available width, because it is designed for this.

Issues Resolved

Platforms Affected

-UWP

Behavioral/Visual Changes

ActivityIndicator in UWP will be displayed when placed in AbsoluteLayout

PR Checklist

  • Has automated tests
  • Rebased on top of the target branch at time of PR
  • Changes adhere to coding standard

Comment thread Xamarin.Forms.Core/AbsoluteLayout.cs Outdated
bool heightIsProportional = (absFlags & AbsoluteLayoutFlags.HeightProportional) != 0;
bool xIsProportional = (absFlags & AbsoluteLayoutFlags.XProportional) != 0;
bool yIsProportional = (absFlags & AbsoluteLayoutFlags.YProportional) != 0;
bool widthIsProportional = absFlags.HasFlag(AbsoluteLayoutFlags.WidthProportional);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We intentionally avoid the HasFlag extension method because it is much slower.

@samhouts samhouts requested a review from jassmith July 5, 2018 17:03
@PureWeen
Copy link
Copy Markdown
Contributor

@paymicro can you rebase to fix the conflicts please?

@samhouts
Copy link
Copy Markdown
Contributor

build --uitests

Comment thread Xamarin.Forms.Core/AbsoluteLayout.cs Outdated
if (!widthIsProportional && bounds.Width == AutoSize)
{
sizeRequest = view.Measure(region.Width, region.Height, MeasureFlags.IncludeMargins);
result.Width = sizeRequest.Request.Width > 0 ? sizeRequest.Request.Width : region.Width;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is quite right and that 0 means AutoSize. This change means if I set the WidthRequest on anything to zero it becomes full width

For example

Content = new AbsoluteLayout()
			{
				Children = {
					new Label(){ Text = "cat", WidthRequest = 0},
					new Image(){ Source = "coffee.png", WidthRequest = 0},
					new ActivityIndicator() { IsRunning = true }
				}
			};

Causes that Label and Image to be full width

If you change out AbsoluteLayout for a StackLayout you'll see that StackLayout will measure the Label and Image to have zero width because a WidthRequest of zero means please only make the width zero.

The fix for this Issue feels like it should be inside the ActivityIndcatorRenderer on UWP
If there's a way there to see that you are allowed to autosize to just fill the region you are in

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@paymicro paymicro changed the title [Core] Fix autosize elements in absolute layout [UWP] Fix ActivityIndicator width in absolutelayout Oct 29, 2018
@samhouts
Copy link
Copy Markdown
Contributor

build

@PureWeen PureWeen merged commit e0e10f1 into xamarin:master Oct 30, 2018
@paymicro paymicro deleted the fix-gh1399-absolute-layout branch October 31, 2018 05:47
@samhouts samhouts added the p/UWP label Nov 2, 2018
@samhouts samhouts added this to the 4.0.0 milestone Dec 4, 2018
@samhouts samhouts modified the milestones: 4.0.0, 3.5.0 Jan 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ActivityIndicator width is autosize in absolutelayout is -1/0 on windows

4 participants