Reputation: 4161
I have the following XML layout:
<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>
The problem is, that for some reason, the wrap_content
for the AdView
RelativeLayout
height attribute causes the whole RelativeLayout
to take up the whole screen. If I set a hard value (50px
) then I get the ScrollView
taking up the whole screen - 50px (Like I want, except that the RelativeLayout
height should be equal to the AdView
height. Does anyone know why the AdView
forces the parent RelativeLayout
to fill the screen?
Note: There are layouts behind these, but they have no influence on this specific issue (As tested by setting height = 50px).
Upvotes: 0
Views: 168
Reputation: 728
Since android:layout_centerHorizontal="true"
wont work with wrap_content
( it works with fill_parent
as it knows the area in which it needs to be centered). Remove the CenterHorizontal code And use wrap_content instead of providing a height value which will not allow to provide Ads dynamically.
Upvotes: 1
Reputation: 107
Try to set the height of the ad to '50dp' and post your results
Upvotes: 2