이 같은 것으로 레이아웃을 수정해야합니다 : 이것은 내 코드입니다
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layoutMain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout1"
android:tag="trueLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
>
</RelativeLayout>
</LinearLayout>
, 자기 설명 :
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LinearLayout layoutMain = (LinearLayout) findViewById(R.id.layoutMain);
// Create the adView
// Please replace MY_BANNER_UNIT_ID with your AdMob Publisher ID
adView = new AdView(this, AdSize.BANNER, "YourPersonalID#");
layoutMain.addView(adView);
// Initiate a generic request to load it with an ad
AdRequest request = new AdRequest();
request.setTesting(true);
adView.loadAd(request);
RelativeLayout layout1 = (RelativeLayout) findViewById(R.id.layout1);
layout1.setOnTouchListener(this);
mTestHarness = new GLSurfaceView(this);
mTestHarness.setEGLConfigChooser(false);
mTestHarness.setRenderer(this);
mTestHarness.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
layout1.addView(mTestHarness);
}
당신이이 권리를 얻을 후에는 해당를 얻을 것이다 Google Play 자습서에서 BannerEssentials 튜토리얼 앱으로 이동하지만 대신 GLSurfaceView를 사용합니다.
레이아웃이 어떻게 생겼습니까? –
자바 코드의 레이아웃을 xml 파일에 설정하지 않았습니다. 코드는 입니다. AdView mAdView = new AdView (this, AdSize.BANNER, "id"); \t FrameLayout 레이아웃 = 새 FrameLayout (this); // (FrameLayout) this.findViewById (R.id.adViewLayout); \t FrameLayout.LayoutParams adsParams = 새 FrameLayout.LayoutParams (FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, android.view.Gravity.BOTTOM | android.view.Gravity.CENTER_HORIZONTAL); \t layout.addView (GLGame.mAdView, adsParams); \t mAdView.loadAd (새 AdRequest()); – appdroid
GLSurfaceView를 동일한 FrameLayout에 추가합니까? 그렇다면 해당 코드를 게시 할 수 있습니다. 그렇지 않다면 그것은 당신의 문제입니다. –