我有以下 XML 布局:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:layout_above="@+id/adcontent1"
android:background="#0000FF">
<TextView
android:id="@+id/tempview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000"
android:layout_alignParentBottom="true"
android:id="@+id/adcontent1" >
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/adview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:adSize="BANNER"
app:adUnitId="lah-di-da"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true">
</com.google.ads.AdView>
</RelativeLayout>
</RelativeLayout>
问题是,由于某种原因,wrap_content
高度AdView
RelativeLayout
属性导致整体RelativeLayout
占据整个屏幕。如果我设置了一个硬值(50px
),那么我会ScrollView
占据整个屏幕 - 50px(就像我想要的那样,除了RelativeLayout
高度应该等于AdView
高度。有谁知道为什么AdView
强迫父母RelativeLayout
填满屏幕?
注意:这些背后有布局,但它们对这个特定问题没有影响(通过设置 height = 50px 进行测试)。