-4

キャンバスのサーフェスビューに admob adbanner を配置したいと考えています。(SurfaceView を拡張し、SurfaceView.Callback を実装するクラス)。ビューを一番上に配置するソリューションはありますか? たとえば、基本的なボタン。

4

1 に答える 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 に答える