2011-02-28 3 views
0

무료 애플리케이션에 AdWhirl을 사용하여 광고를 배치하고 있습니다. MapView 아래 및 ListView 위에 광고를 표시하고 싶습니다. 아무리 노력해도 광고가 바닥을 제외하고는 어디에도 게재되지 않습니다. 현재 listView는 XML에서 확장되지만 AdWhirlView는 Java 코드에서 만들어야합니다. 세로 방향으로 LinearLayout에서 addView (adWhirlView)를 호출하므로 항상 광고가 아래쪽에 표시됩니다. 어떻게 광고를 배치해야하는지 정의 할 수 있습니까? 여기 Android 레이아웃, addView를 호출하기 전에 요소의 순서를 지정하는 방법

내 XML의 :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"   
      android:orientation="vertical" 
      android:layout_width="fill_parent"    
      android:layout_height="fill_parent"   
      android:id="@+id/layout_main" 
      > 
      <RelativeLayout 
       android:layout_width="fill_parent" 
       android:layout_height="0px" 
       android:layout_weight="1">    


      <com.google.android.maps.MapView 
       .... 

     </RelativeLayout>     


      <ListView 
      android:id="@+id/listView"   
      android:layout_width="fill_parent" 
      android:layout_height="0px" 
      android:layout_weight="1"/> 


</LinearLayout> 

답변

0

코드

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"   
     android:orientation="vertical" 
     android:layout_width="fill_parent"    
     android:layout_height="fill_parent"   
     android:id="@+id/layout_main" 
     > 
     <RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="0px" 
      android:layout_weight="1">    


     <com.google.android.maps.MapView 
      .... 

    </RelativeLayout>     

    <LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:id="@+id/layout_ad" 
    android:layout_height="wrap_content" /> 
     <ListView 
     android:id="@+id/listView"   
     android:layout_width="fill_parent" 
     android:layout_height="0px" 
     android:layout_weight="1"/> 
</LinearLayout> 

아래 시도하고 다음 코드 사용을 사용

AdManager.setTestDevices(new String[] { AdManager.TEST_EMULATOR }); 
LinearLayout layout = (LinearLayout) findViewById(R.id.layout_ad); 
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this, "Key"); 
Display d = this.getWindowManager().getDefaultDisplay(); 
RelativeLayout.LayoutParams adWhirlLayoutParams = new RelativeLayout.LayoutParams(d.getWidth(), 52); 
layout.addView(adWhirlLayout, adWhirlLayoutParams); 
layout.invalidate(); 

목록보기는 항상 애드 월 후으로 들어오는 것입니다 이런 식으로 표시 할 광고가 없습니다. 목록보기는지도 바로 다음에옵니다.

+0

완벽! 결국, 안드로이드가 누락되었습니다 : layout_height = "wrap_content" –

관련 문제