如何在SurfaceView显示Admob的如何在、SurfaceView、Admob

2023-09-09 22:12:25 作者:燃烧吧少年

我尽量表现Admob的在我的SurfaceView。

I try to show Admob on my SurfaceView.

在我使用的框架,从本书从马里奥Zechner 开始的Andr​​oid游戏 在框架内还有一类(AndroidFastRenderView扩展了SurfaceView实现Runnable接口),并在这个类有行canvas.drawBitmap(帧缓冲,空,dstRect,NULL);其中,帧缓存为位图,其中的所有画在游戏中。 在此框架内还有一类(AndroidGame扩展活动)哪里是行的setContentView(的RenderView); I use framework from book beginning android games from Mario Zechner In framework there is a class (AndroidFastRenderView extends SurfaceView implements Runnable) and in that class there is line canvas.drawBitmap(framebuffer, null, dstRect, null); where framebuffer is Bitmap where is all drawn in game. In that framework there is a class (AndroidGame extends Activity) where is line setContentView(renderView);

下面的RenderView是AndroidFastRenderView即SurfaceView,现在我尝试添加Admob的,但我不无如何。

Here renderView is AndroidFastRenderView that is SurfaceView, Now I try to add Admob but I don't no how.

我可以创建Admob的像这样

I can create Admob like this

AD浏览报AD浏览报=新的AD浏览报(这一点,AdSize.BANNER,身份识别码);

AdView adView = new AdView(this, AdSize.BANNER, "MyID");

但如果补充一点看法

感谢您的帮助。

推荐答案

AdMob的广告目录示例应用程序有类似这样的例子。在上面的例子中, AD浏览报在XML中被定义。但在较高的水平,你可能会想是这样的:

AdMob's Ad Catalog sample application has an example similar to this. In the above example, the AdView was defined in XML. But at a high level, you'll probably want something like this:

<RelativeLayout ...>
    <AdView ...
        android:id="@+id/adView"
        android:layout_alignParentBottom="true"/>
    <AndroidFastRenderView ...
        android:layout_above="@id/adView"/>
</RelativeLayout>

AD浏览报坐落在顶部或底部外AndroidFastRenderView的。如果你这样做是在code,我建议你创建一个 RelativeLayout的添加 AD浏览报作为 RelativeLayout的的子视图底部(例如),然后添加的RenderView 作为一个子视图 RelativeLayout的,但高于 AD浏览报

Where the AdView sits at the top or bottom outside of the AndroidFastRenderView. If you're doing it in code, I'd suggest you create a RelativeLayout, add the AdView as a subView of the RelativeLayout at the bottom (for example), and then add the renderView as a subView of the RelativeLayout, but above the AdView.