我正在尝试为我的应用设置AdMob横幅。在我的Activity中我有一个ListView,所以我需要将Banner放在它的底部。 admob横幅出现在屏幕中间。如何在屏幕底部修复它? 这是代码:
?name
答案 0 :(得分:2)
似乎问题是因为您的代码不在RelativeLayout容器中,并且属性<div class="main">
<h1>Title</h1>
<h2>tagline</h2>
<div id="container">
<!-- Module1 -->
<div class="module">
<div class="module-child">
<p><strong>Module 1</strong></p>
<p>lorem ipsum</p>
<p>lorem ipsum</p>
<p>lorem ipsum</p>
</div>
<div id="mc_embed_signup" class="module-child">
<form>
<div>
<div><input name="EMAIL" type="email" value="" placeholder="email address" /></div>
<div><input type="submit" value="button" /></div>
</div>
</form>
</div>
</div>
<!-- Module2 -->
<div class="module">
<div class="module-child">
<p><strong>Module 2</strong></p>
<p>lorem ipsum</p>
</div>
<div id="mc_embed_signup" class="module-child">
<form>
<div>
<div><input name="EMAIL" type="email" value="" placeholder="email address" /></div>
<div><input type="submit" value="button" /></div>
</div>
</form>
</div>
</div>
<!-- Module3 -->
<div class="module">
<div class="module-child">
<p><strong>Module 3</strong></p>
<p>lorem ipsum</p>
</div>
<div id="mc_embed_signup" class="module-child">
<form>
<div>
<div><input name="EMAIL" type="email" value="" placeholder="email address" /></div>
<div><input type="submit" value="button" /></div>
</div>
</form>
</div>
</div>
</div>
</div>
将无法正常工作,此代码将适合您:
android:layout_alignParentBottom="true"
答案 1 :(得分:0)
如果我没有弄错你,你在FrameLayout中切换片段,所以你可以尝试在屏幕底部显示和隐藏广告视图。别忘了改变AdView的可见性。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Framelayout to display Fragments -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:weight="1" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="50dp"
android:visibility="gone"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
</LinearLayout>
<!-- Listview to display slider menu -->
<ListView
android:id="@+id/list_slidermenu"
android:layout_width="270dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@drawable/sidebar_gradient"
android:choiceMode="singleChoice"
android:divider="@color/white_60_per_trans"
android:dividerHeight="0.5dp" />
</RelativeLayout>
我希望它会有所帮助!