Refreshing Height & Width of a View in Xamarin.Android

Nathan Sokalski 4,116 Reputation points
2021-03-05T21:37:29.613+00:00

I have an Extension Method that displays a View (a TextView to be specific). The View usually has a Visibility of Gone before the method is called, so the first thing I do in the method is set Visibility to Visible. However, the Width & Height properties are still 0 at this point. The next time I call the method, the Width & Height are updated, however, I need to update them immediately after setting Visibility to Visible so that I can use them in the Extension Method. How do I do this? (NOTE: I will mention, in case it makes any difference, that android:layout_width is set to a literal value in the xml, but android:layout_height is just the usual wrap_content) Thanks.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,294 questions
{count} votes