【问题标题】:adMob | Smart banner at bottom?移动广告 |底部的智能横幅?
【发布时间】:2014-11-23 14:20:42
【问题描述】:

这个想法是将admob横幅放在我尝试使用android:layout_alignParentBottom = "true"的屏幕底部,但横幅站在它占据的位置的中间。目前看起来像这样:pic1 我想看起来像这样:pic2

我的代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background"
    android:orientation="vertical"
    tools:context="eu.gabrielatanasov.demoViewer.Home_activity" >

<LinearLayout
        android:id="@+id/homeContentLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin" >

应用程序在这里

</LinearLayout>
<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_below="@id/homeContentLayout"
    ads:adSize="SMART_BANNER"
    ads:adUnitId="@string/adMob_ID" >
</com.google.android.gms.ads.AdView>

</RelativeLayout>

【问题讨论】:

  • 哦..尝试不同的高度
  • 要设置什么高度?
  • com.google.android.gms.ads.AdView 中的layout _height 属性。
  • 我的意思是用什么来替换 match_parent?
  • ha...将 match_parent 替换为其他静态值或 wrap_content..

标签: android admob smartbanner


【解决方案1】:

我稍微修改了你的布局,看看这个:

<RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
    <LinearLayout
            android:id="@+id/homeContentLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_above="@+id/adView">
    </LinearLayout>
    <com.google.android.gms.ads.AdView
            android:id="@+id/adView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignWithParentIfMissing="true"
            ads:adSize="SMART_BANNER"
            ads:adUnitId="admobid">
    </com.google.android.gms.ads.AdView>

</RelativeLayout>

【讨论】:

    【解决方案2】:

    像这样编辑您的 content_main.xml 文件:

        <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        tools:showIn="@layout/app_bar_main">
    
        <FrameLayout
            android:id="@+id/fragmentContainer"
            android:layout_width="match_parent"
            android:layout_above="@+id/adView"
            android:layout_height="match_parent"
            android:orientation="vertical" />
    
        <com.google.android.gms.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            ads:adSize="BANNER"
            ads:adUnitId="@string/banner_home_footer">
        </com.google.android.gms.ads.AdView>
    
    </RelativeLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-01
      • 2016-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-26
      相关资源
      最近更新 更多