Android 如何使Admob adblock离开屏幕中心?
我是Android开发新手,我正在尝试学习如何将Admob添加到现有应用程序中。使用Admob SDK说明,我已经能够在我尝试过的几个应用程序上成功地做到这一点。我有一个,但我的生活,我不能去底部的屏幕,因为它应该。我知道main.xml中有一些内容,但我无法理解 下面是我现在掌握的将广告块放在屏幕中央的代码:Android 如何使Admob adblock离开屏幕中心?,android,admob,Android,Admob,我是Android开发新手,我正在尝试学习如何将Admob添加到现有应用程序中。使用Admob SDK说明,我已经能够在我尝试过的几个应用程序上成功地做到这一点。我有一个,但我的生活,我不能去底部的屏幕,因为它应该。我知道main.xml中有一些内容,但我无法理解 下面是我现在掌握的将广告块放在屏幕中央的代码: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.an
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg">
<ImageView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/eight_ball"
android:layout_gravity="center_vertical"
android:layout_margin="10px" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<TextView android:id="@+id/MessageTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/triangle"
android:text="@string/shake_me_caption"
android:focusable="false"
android:gravity="center_vertical|center"
android:layout_marginTop="14dip">
</TextView>
</LinearLayout>
</FrameLayout>
正如我所说的,我非常确定main.xml需要工作(可能还需要对主活动中的代码进行一些调整),但无论我尝试了什么,广告块要么留在中间,要么完全消失
提前感谢。
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId=""
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
将此代码放在xml文件中您希望放置的任何位置。您不需要编写在java文件中编写的代码
只需将此代码插入xml。就这些。
干杯。
将此代码放在xml文件中您希望放置的任何位置。您不需要编写在java文件中编写的代码
只需将此代码插入xml。就这些。
干杯。谢谢,这非常有效。我不敢相信事情竟那么简单。我想我有很多东西要学。:)谢谢,效果很好。我不敢相信事情竟那么简单。我想我有很多东西要学。:)
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId=""
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>