2014-09-09 3 views
0

내 앱의 하단에 AdView를 배치하려고합니다. 그러나 앱을 테스트 할 때 광고 나 AdView가 표시되지 않습니다.AdView가 앱 하단에 표시되지 않습니다.

내 MainActivity에서 2 FrameLayouts를 2 조각으로 바꿉니다. 따라서 AdView는 세 번째 조각 뒤에 표시되어야합니다.

여기 여기 CardListView 조각에 의해 사용되는 레이아웃의 내 main_activity.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 

    android:id="@+id/layout_id" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <FrameLayout 
     android:id="@+id/fragment_content" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" /> 

    <FrameLayout 
     android:id="@+id/fragment_content2" 
     android:layout_width="fill_parent" 
     android:layout_height="500dp" /> 

    <com.google.android.gms.ads.AdView 
     xmlns:ads="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/adView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     ads:adSize="BANNER" 
     ads:adUnitId="app_id"/> 
</LinearLayout> 

Main_activity.java

@Override 
    protected void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main_activity); 

     adView = (AdView) findViewById(R.id.adView); 

     AdRequest adRequest = new AdRequest.Builder() 
     .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) 
     .addTestDevice("5554:Perfect_One") 
     .build(); 

     // Start loading the ad in the background. 
     adView.loadAd(adRequest); 

     myContext = this; 

     fragmentManager = this.getFragmentManager(); 

     Fragment frag = new SortFeature(); 
     FragmentTransaction ft = fragmentManager.beginTransaction(); 
     ft.replace(R.id.fragment_content, frag); 
     ft.commit(); 

     Fragment frag2 = new CardListView(); 
     FragmentTransaction ft2 = fragmentManager.beginTransaction(); 
     ft2.replace(R.id.fragment_content2, frag2); 
     ft2.commit(); 

입니다.

09-08 21:22:29.578: I/Ads(2050): JS: Creating Application Cache with manifest http://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.appcache (http://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html:0) 

09-08 21:22:29.588: I/chromium(2050): [INFO:CONSOLE(0)] "Creating Application Cache with manifest http://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.appcache", source: http://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html (0) 

09-08 21:22:29.618: I/Ads(2050): JS: Application Cache Checking event (http://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html:0) 

09-08 21:22:49.629: W/Ads(2050): Not enough space to show ad. Needs 320x50 dp, but only has 320x0 dp. 
+0

게시물 추적을 게시하면 '광고를 표시 할 공간이 충분하지 않습니다'와 같은 메시지가 표시됩니까? – LightYearsBehind

+0

나는 너에게하고 싶다. 아쉽게도 내 logcat이 현재 작동하지 않습니다. 다시 작동하게하려면 Eclipse와 에뮬레이터를 다시 시작합니다. – Pierre

+0

내 logcat을 게시했습니다. 광고 게재를위한 충분한 공간이 없다는 것을 알았습니다. 그러나, 나는 그것을위한 더 많은 공간을 만드는 방법을 알아낼 수 없습니다. – Pierre

답변

1

마지막으로, 나는 그것이 작동하도록 관리 :

<ListView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/listview" 
android:layout_width="match_parent" 
android:layout_height="500dp" 
android:background="@drawable/background" /> 

여기 내 로그 캣입니다. 문제는 광고가 게재 될 충분한 공간이 없다는 것입니다.

내 CardListView 조각의 높이는 500dp입니다. 그것은 너무 많았습니다. 나는 그것을 300dp로 줄 였고 이제 Adview가 적절하다는 것을 알 수 있습니다.

+1

제대로 작동하려면 여러 화면 크기에 대해이 치수 값을 조정해야하지만 일부 화면 크기를 놓치게 될 확률은 100 %입니다. 제 제안은 두 번째 조각을'layout_height = "0dp"'로 바꾸고 대신'layout_weight = "1"'을 설정하는 것입니다. – LightYearsBehind

+0

두 번째 조각 앞에 AdView를 배치 할 수 있습니까? 그래서 Adview는 두 번째 조각의 작은 부분을 차지합니까? – Pierre

+0

FrameLayout 자체로 하나의 뷰를 다른 뷰 위에 오버레이 할 수 있지만이 경우에는 윗면 뷰가 아래 뷰의 일부를 포함 할 수 있습니다. 두 개의 조각을 겹치지 않고 함께 표시하려면 두 번째 조각과 AdView를 다른 LinearLayout에 넣으십시오. – LightYearsBehind

관련 문제