Android Beginner: Prevent admob from pushing content up(Android初学者:防止admob向上推送内容)
问题描述
我是初学者,请耐心等待.我有一个带有几个按钮的布局,然后在底部有一个 adview.当广告加载时,它会向上推动按钮并使它们变得非常小.有没有办法防止内容被推上去?
I am a beginner so bear with me. I have a layout with several buttons and then an adview at the bottom. When the ad loads, it pushes the buttons up and makes them very small. Is there anyway to prevent the content from being pushed up?
这是我的代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_hdpi" >
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="a14fc541226f07b"
ads:loadAdOnCreate="true" >
</com.google.ads.AdView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/ad"
android:orientation="vertical"
android:weightSum="7.0" >
<Button
android:id="@+id/basics1"
android:layout_width="150.0dip"
android:layout_height="0.0dip"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="2.0dip"
android:layout_marginTop="100.0dip"
android:layout_weight="1.0"
android:text="Overview"
android:textSize="16.0sp" />
<Button
android:id="@+id/basics2"
android:layout_width="150.0dip"
android:layout_height="0.0dip"
android:layout_gravity="center_horizontal"
android:layout_margin="2.0dip"
android:layout_weight="1.0"
android:text="Campaign"
android:textSize="16.0sp" />
<Button
android:id="@+id/basics3"
android:layout_width="150.0dip"
android:layout_height="0.0dip"
android:layout_gravity="center"
android:layout_margin="2.0dip"
android:layout_weight="1.0"
android:text="Special Ops"
android:textColor="#ff000000"
android:textSize="16.0sp" />
<Button
android:id="@+id/basics4"
android:layout_width="150.0dip"
android:layout_height="0.0dip"
android:layout_gravity="center_horizontal"
android:layout_margin="2.0dip"
android:layout_weight="1.0"
android:text="Zombies"
android:textColor="#ff000000"
android:textSize="16.0sp" />
<Button
android:id="@+id/basics5"
android:layout_width="150.0dip"
android:layout_height="0.0dip"
android:layout_gravity="center_horizontal"
android:layout_margin="2.0dip"
android:layout_weight="1.0"
android:text="Modes"
android:textColor="#ff000000"
android:textSize="16.0sp" />
<Button
android:id="@+id/basics6"
android:layout_width="150.0dip"
android:layout_height="0.0dip"
android:layout_gravity="center_horizontal"
android:layout_margin="2.0dip"
android:layout_weight="1.0"
android:text="Ranks/Unlocks"
android:textColor="#ff000000"
android:textSize="16.0sp" />
</LinearLayout>
</RelativeLayout>
推荐答案
你有几个选择.
将按钮设置为固定大小,而不是依赖于重量.权重使您的按钮占用了可用空间的一小部分.因此,当广告加载时,可用空间会减少,然后您的按钮会变小.
Make your buttons a fixed size instead of weight dependent. Weights make your Buttons take up a fraction of the space available. So when the ad loads, the space available decreases and then your buttons become smaller.
将RelativeLayout 更改为FrameLayout 并将广告放在LinearLayout 按钮之后.
Change your RelativeLayout into a FrameLayout and put the ads after the button LinearLayout.
把所有东西都放到ScrollView里面,即:
Put everything inside ScrollView, ie:
RelativeLayout -> ScrollView -> LinearLayout (height:wrap_content,width:fill_parent) -> AdView + LinearLayout with Buttons
RelativeLayout -> ScrollView -> LinearLayout (height:wrap_content,width:fill_parent) -> AdView + LinearLayout with Buttons
这篇关于Android初学者:防止admob向上推送内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android初学者:防止admob向上推送内容
基础教程推荐
- 在螺旋中写一个字符串 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01