adMobの表示位置を中央揃えにしたい
andEngien本(andEngineでつくるAndroid2Dゲーム)ではFrameLayoutに書き換えるようにという風になっている。
7インチタブレットなどの解像度の高い画面で見ると左下に表示されてしまうので中央下にするためにRalativLayoutでやる方法
以下、中央下に表示する例
7インチタブレットなどの解像度の高い画面で見ると左下に表示されてしまうので中央下にするためにRalativLayoutでやる方法
以下、中央下に表示する例
layout/activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#Fff" >
<org.andengine.opengl.view.RenderSurfaceView
android:id="@+id/renderview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="パブリッシャーID"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_DEVICES" >
</com.google.ads.AdView>
</RelativeLayout>
あとはグラフィカル・レイアウトでドラッグして上中央にするもよし、右下にするもよし 思ったより簡単だった


0 件のコメント:
コメントを投稿