I created a basic demo to test the function, the layout's height will be updated when the hidden imageView becomes visible. Here is the related code, you could refer to:
layout.xaml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="@+id/btn1"
android:text="button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:hint="edit test"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btn2"
android:text="button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/grid_"
android:visibility="gone"/>
</LinearLayout>
</LinearLayout>
Activity.cs
public class Activity1 : Activity
{
Button btn1;
Button btn2;
LinearLayout layout;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.layout1);
// Create your application here
btn1 = FindViewById<Button>(Resource.Id.btn1);
btn2 = FindViewById<Button>(Resource.Id.btn2);
btn1.Click += Btn1_Click;
btn2.Click += Btn2_Click; ;
layout = FindViewById<LinearLayout>(Resource.Id.layout);
}
private void Btn1_Click(object sender, EventArgs e)
{
Console.WriteLine("Layout's Height: " + layout.Height);
}
private void Btn2_Click(object sender, EventArgs e)
{
var img = FindViewById<ImageView>(Resource.Id.img);
if (img.Visibility == ViewStates.Gone)
{
img.Visibility = ViewStates.Visible;
}
else
{
img.Visibility = ViewStates.Gone;
}
}
}