如何添加广告,Android应用没有与我的内容重叠 [英] how to add ads to android app without overlapping with my content

查看:139
本文介绍了如何添加广告,Android应用没有与我的内容重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加广告我的应用程序(这是我第一次),但它总是与我的内容重叠(即它显示在我的内容)。

I am adding ads to my app (This is my first time) but it always overlap with my content (i.e. it is shown over my content).

我的XML是:

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:androidsam="http://schemas.android.com/apk/res/com.jameselsey"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">


<LinearLayout android:layout_width="fill_parent"
                  android:id="@+id/home_layout"
                  android:orientation="vertical"
                  android:layout_height="wrap_content"
                  android:background="@drawable/background">

     <TextView
        android:id="@+id/my_text"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:scrollbars="vertical"
        android:text="TextView2"
        android:textColor="#ffffff" 
        android:textColorHighlight="#000000"
        android:shadowColor="#000000"
        android:shadowDx="3"
        android:shadowDy="-3"
        android:shadowRadius="1.5"
        android:fadingEdge="horizontal"
        android:typeface="serif"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        />

</LinearLayout>   





<LinearLayout 
                  xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
                  android:layout_width="fill_parent"
                  android:id="@+id/ad_layout"
                  android:layout_height="wrap_content"
                  android:layout_alignParentBottom="true"
                >
<com.google.ads.AdView android:id="@+id/adView"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         ads:adUnitId="a14f26e5d930307"
                         ads:adSize="BANNER"
                         ads:testDevices="TEST_EMULATOR, 33334750709D00EC"
                         ads:loadAdOnCreate="true"/>
    </LinearLayout>


</RelativeLayout>

该广告显示在屏幕的底部,但它隐藏的TextView的结束!
任何想法要做到这一点,而不与TextView的重叠?

The ad is shown at the bottom of the screen but it hides the end of the TextView! Any ideas to do this without overlapping with the TextView ?

在此先感谢:)

推荐答案

您可以使用结构如下。对齐AdView中的android:layout_alignParentBottom =真正的和LinearLayout中的属性设置为 Android的调整您的LinearLayout本的AdView以上:layout_above =@ ID / AD浏览

You can use structure as given below. Align adView to android:layout_alignParentBottom="true" and align your LinearLayout above this adView by setting LinearLayout's attribute to android:layout_above="@id/adView".

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:androidsam="http://schemas.android.com/apk/res/com.jameselsey"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        ads:adSize="BANNER"
        ads:adUnitId="xxxxxxxxxxxx"
        ads:loadAdOnCreate="true"
        ads:testDevices="TEST_EMULATOR" />

    <LinearLayout
        android:id="@+id/home_layout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/adView"
        android:background="@drawable/background"
        android:orientation="vertical" >

        <!-- Your layout components should be here-->

    </LinearLayout>

</RelativeLayout>

这篇关于如何添加广告,Android应用没有与我的内容重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆