-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In Android, adding views in SizeChanged event does not show the newly added views #19391
Comments
Hi @last-Programmer. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Here is the project that is happening the bug |
Can you test with the latest nightly? |
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process. |
It seems to be that it is working fine with nightly build. I have this sample code namespace MauiApp1;
public class MainPage : ContentPage
{
private bool initiated;
private VerticalStackLayout layout;
public MainPage()
{
this.SizeChanged += OnSizeChanged;
}
private void OnSizeChanged(object? sender, EventArgs e)
{
if (!this.initiated)
{
this.initiated = true;
this.CreateControls();
}
}
private void CreateControls()
{
this.layout = new VerticalStackLayout();
this.layout.VerticalOptions = LayoutOptions.Fill;
this.layout.HorizontalOptions = LayoutOptions.Fill;
this.layout.BackgroundColor = Colors.Brown;
Label label = new Label
{
FontSize = 20,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
VerticalTextAlignment = TextAlignment.Center,
HorizontalTextAlignment = TextAlignment.Center,
Text = ".NET MAUI ROCKS",
BackgroundColor = Colors.Black,
TextColor = Colors.White
};
this.layout.Children.Add(label);
this.Content = this.layout;
}
} The label is not centering vertically. Is there something i am doing wrong. This is happening with both stable and nightly build. |
@last-Programmer can you create a new issue? Does it center if you create it at startup vs inside SizeChanged? Once this is resolved it might fix your second issue |
Hi, The problem is not only adding new controls. I have a button IsVisble = false in already created control in the constructor. on size changed if i change IsVisible to true the button is not becoming visibile. this works find in iOS. it is not working in android. There seems to be some issue in updating the screen when adding new controls or modifying the properties of existing controls does not work with Android. |
Description
In Android, adding views in SizeChanged event does not show the newly added views
Steps to Reproduce
Run the project in Android simulator and you can see that the newly added label is not shown. But when you run the same in iOS simulator it is shown. I need to add the views in SizeChanged because i need to know size of the parent containers size to to create new child views based on parent container size.
Link to public reproduction project repository
No response
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: