Android AdMob Position top of screen not working

后端 未结 2 565
清酒与你
清酒与你 2020-12-04 03:42

I am trying to integrate AdMob into my Android Application, and can get it to work fine in the simulator when using the default sample layout code to position AdMob at the b

相关标签:
2条回答
  • 2020-12-04 04:36

    If you always want to display on top of the screen then you may want to consider using RelativeLayout.

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    
    <com.admob.android.ads.AdView
          android:id="@+id/ad" 
          android:layout_width="fill_parent" 
          android:layout_height="wrap_content"
          app:backgroundColor="#000000"
          app:primaryTextColor="#FFFFFF"
          app:secondaryTextColor="#CCCCCC"
          android:layout_alignParentTop="true"
        />
    
    <!-- TextView below that -->
    
    <TextView
    android:id="@+id/widget28"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Input Amount:"
    android:layout_marginLeft="10dip"
    android:layout_marginTop="10dip"
    android:layout_marginRight="10dip"
    android:layout_below="@id/ad"
    android:textSize="16dip"
    android:textStyle="bold">
    </TextView>
    
    </RelativeLayout>
    
    0 讨论(0)
  • 2020-12-04 04:45

    Make sure you are not scaling the emulator screen as this has caused me problems whereby the ads don't appear. I have also had to set the ads layout_height="50dip" to make sure the ads don't suddenly push the other Views (controls) down the screen and mess up the layout.

    0 讨论(0)
提交回复
热议问题