Android的加入广告(AdMob的),到OpenGL ES屏 [英] Android add advert (admob) to OPENGL-ES screen

查看:144
本文介绍了Android的加入广告(AdMob的),到OpenGL ES屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法做到这一点?我是新来的OpenGL-ES。我找不到任何信息如何将广告添加到一个简单的glsurfaceview。

Is there a way to do this? I am new to opengl-es. I cant find any information how to add an advert to a simple glsurfaceview.

推荐答案

您不会需要借助自己的广告在你的OpenGL表面所有,只是设置一些布局,以您的活动为内容的看法,并添加广告和表面的布局。

You won't need to draw ads yourself on your OpenGL surface at all, just set some layout to your activity as the content view, and add the ad and the surface to the layout.

您可以使用的的FrameLayout 的,如果你不介意的广告将覆盖你的面,或 RelativeLayout的的,如果你需要一个专门的区域,比方说,在顶部,但要确保你把下面的广告一些不错的旗帜,以避免显示一个黑盒子的情况下,有没有网络连接。

You can use a FrameLayout if you don't mind that the ad will cover your surface, or a RelativeLayout if you need a dedicated area, say, on the top, but make sure you put some nice banner below the ads to avoid showing a black box in case there is no network connection.

我们通过使用Admob的 Adwhirl 的,所以在我们的例子中,它看起来像下面这样。我从来没有使用过Admob的直接,但我想它应该是真正的相似。

We use Admob via Adwhirl, so in our case it looks something like the following. I never used Admob directly, but I guess it should be something really similar.

的main.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout_main"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
</FrameLayout>

YourActivity.java

FrameLayout layout = (FrameLayout) findViewById(R.id.layout_main);

GLSurfaceView surface = ...
FrameLayout.LayoutParams surfaceParams = new FrameLayout.LayoutParams(...);
layout.addView(surface, surfaceParams);

AWhirlLayout adWhirlLayout = ...
FrameLayout.LayoutParams adsParams = new FrameLayout.LayoutParams(...);
mainLayout.addView(adWhirlLayout, adsParams);

这篇关于Android的加入广告(AdMob的),到OpenGL ES屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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