在屏幕下方的Andr​​oid叠加 [英] Android Overlay at bottom of the screen

查看:214
本文介绍了在屏幕下方的Andr​​oid叠加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要实现我的应用程序的广告,但我想要实现
在覆盖视图广告,应用程序的主要内容应该是
前景和覆盖是顶级的主要内容,我想
在屏幕的底部对齐overaly。请告诉我如何
我可以在我的屏幕???

I want to implement the ads in my app but I want to implement the ads on an overlay view, The main content of the app should be foreground and the overlay is top of the main content and I want to align the overaly at the bottom of the screen. Kindly tell me how I can achieve the overlay at the bottom of my screen???

推荐答案

实现这一目标的最简单方法是使用的FrameLayout作为根视图。下面是一些code来证明这一点。我没有测试过这个特殊的例子,但它应该有轻微修改AdView的属性工作。

The simplest way to achieve this is to use a FrameLayout as your root view. Here is some code to demonstrate this. I haven't tested this particular example, but it should work with slight modification to the AdView attributes.

<FrameLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
    <LinearLayout
        android:id="@+id/main_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <!-- Your main layout code goes here -->
    </LinearLayout>
    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        ads:adUnitId="MY_AD_UNIT_ID"
        ads:adSize="BANNER"
        ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
        ads:loadAdOnCreate="true"/>
</FrameLayout>

请注意AdView中的layout_gravity属性;那是什么原因导致它出现在屏幕的底部。

Note the layout_gravity attribute of the AdView; that's what causes it to appear at the bottom of the screen.

这篇关于在屏幕下方的Andr​​oid叠加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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