2016-11-24 4 views
0

저는 Android 레이아웃에 익숙하지 않으며 기본보기의 맨 아래에 AdView를 추가하고 기본보기를 위로 이동하여 높이를 줄이려고합니다. . 어딘가에 코드를 가져 와서 광고를 하단에 표시했지만 애플리케이션의 높이는 줄어들지 않습니다. 광고는 애플리케이션의 하단을 차지합니다. xml없이 프로그래밍 방식으로 만들어야합니다. 사전에Android : 하단에 광고 추가 및 다른보기 축소

adView.setVisibility(View.VISIBLE); 
    adView.loadAd(new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build()); 

감사 : 얼마 후 내가 같이 adView를 보여

View mainView; // of type SurfaceView 
    adView = new AdView(this); 
    adView.setAdUnitId("ca-app-pub-3940256099942544/6300978111"); 
    adView.setAdSize(AdSize.SMART_BANNER); 
    mainLayout = new RelativeLayout(this); 
    mainLayout.addView(mainView); 
    RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 
    adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); 
    mainLayout.addView(adView, adParams); 
    setContentView(mainLayout);  

:

내가 가지고있는 코드입니다.

답변

0

저는 Android에서도 상당히 익숙하지만 adView에 레이아웃 맞춤 태그를 추가해야하는 것처럼 들립니다. 응용 프로그램을 밀어 넣고 하단에 추가해야합니다. 이게 조금 도움이 되었길 바래요!

0

그에게 간단한 :

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical"> 

<LinearLayout 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    android:orientation="vertical" 
    android:layout_weight="1.0"/> 

<LinearLayout 
    android:layout_height="60dp" 
    android:layout_width="match_parent" 
    android:orientation="vertical"> 

    <TextView 
     android:layout_height="wrap_content" 
     android:text="add your ad here" 
     android:layout_width="wrap_content"/> 

</LinearLayout> 

+0

그리고 난 아무 XML을, 그 프로그래밍 방식으로 할 수있는 방법? –

+0

정확히 무엇을 얻으려고합니까? –

+0

레이아웃은 사용자 인터페이스를 위해 만들어 졌으므로 적어도 코드와 함께해야한다면 적어도 레이아웃에 표시해야합니다. https://www.tutorialspoint.com/android/android_user_interface_layouts.htm https://www.tutorialspoint.com/android/android_acitivities.htm –