![](/img/trans.png)
[英]I need admob smart banner to be on bottom of app (using XML if possible)
[英]adMob | Smart banner at bottom?
想法是將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>
我對您的布局做了一些修改,請查看以下內容:
<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>
像這樣編輯您的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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.