A Microsoft framework for building cross-platform mobile apps using .NET and C# with native performance and user interfaces.
Hello,
Welcome to our Microsoft Q&A platform!
if I do call it, the app seems to appear & function correctly, but it ends up in an infinite loop of calling the LayoutChange event.
This is because calling the recyclerView.RequestLayout would trigger the parent layout's LayoutChanged event. To avoid this, try adding a bool parameter to prevent calling the code multi times.
Here is the sample code, you could refer to it.
bool statusValue = true;
private void incEditPlayerNames_LayoutChange(object sender, LayoutChangeEventArgs e)
{
if (statusValue)
{
if (this.IsKeyboardOpen() && Resources.Configuration.Orientation == Android.Content.Res.Orientation.Landscape)
{
this.incEditPlayerNames.GetChildAt(0).Visibility = ViewStates.Gone;
this.btnSavePlayerNames.Visibility = ViewStates.Gone;
this.btnCancelChangesPlayerNames.Visibility = ViewStates.Gone;
}
else
{
this.incEditPlayerNames.GetChildAt(0).Visibility = ViewStates.Visible;
this.btnSavePlayerNames.Visibility = ViewStates.Visible;
this.btnCancelChangesPlayerNames.Visibility = ViewStates.Visible;
}
this.rvPlayerNamesInput.RequestLayout();
statusValue = false;
}
else
{
statusValue = true;
}
}
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.