我想在画布表面视图上放置一个 admob 广告。(扩展 SurfaceView 并实现 SurfaceView.Callback 的类)。将视图放在顶部的任何解决方案?例如一个基本按钮。
问问题
565 次
1 回答
1
其实你不需要将它添加到你的 SurfaceView 中,你可以在添加 SurfaceView 之后将它添加到你的 SurfaceView 的父 ViewGroup 中。
伪示例:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<SurfaceView
android:id="@+id/surface"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true" />
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
ads:adSize="BANNER"
ads:adUnitId="xxxxxxxxxxxxxxxxxx"
android:visibility="visible" />
</RelativeLayout>
使用代码而不是 xml 也可以实现相同的...
于 2013-05-23T10:59:19.373 回答