Android 当布局中的另一个视图随后更改大小时,0dp视图无法正确调整大小

Android 当布局中的另一个视图随后更改大小时,0dp视图无法正确调整大小,android,layout,Android,Layout,我有一个这样的布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/b

我有一个这样的布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:background="@drawable/bg"
   android:orientation="vertical"
   tools:context=".MainActivity" >

<TextView
    android:id="@+id/textView1"
    android:textColor="@android:color/black"
    android:background="#CCFFFFFF"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Press button to start"
    android:gravity="center"
    android:textAppearance="?android:attr/textAppearanceLarge"/>

<MySurfaceView
    android:id="@+id/surfaceView"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:paddingTop="20dp"
    android:paddingBottom="20dp"
    />

<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textColor="@android:color/white"
    android:text="Start process" 
    android:textSize="35sp"/>

<MyAdView
    xmlns:ap="http://schemas.android.com/apk/res-auto"
    android:id="@+id/myAdView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    ap:animation="fade"
    ap:banner_type="inappad"
    ap:placementType="interstitial"
    ap:test_mode="false"
    ap:canShowMR="false"></MyAdView>
</LinearLayout>

视图“myAdView”是一个广告横幅,当从服务器接收到其内容时,它会调整大小。出现这种情况时,横幅高度会调整大小,但id为“@+id/surfaceView”且动态调整大小(高度为0dp)的曲面视图不会根据新的布局视图大小调整大小。我怎样才能解决这个问题?我尝试过几种解决方案,但没有一种奏效


提前感谢。

您能提供更多的细节吗?目前我没有任何代码处理布局。不知道这是否是你想要的。所有内容都是从我发布的布局xml文件生成的。主要问题是,最初横幅的高度为0,因为尚未从服务器检索横幅,收到横幅时,横幅的高度会增加以容纳横幅,但具有0dp的视图不会收缩以调整其大小,因为现在可用空间变少了。