【发布时间】:2014-05-31 11:20:47
【问题描述】:
我想在页面底部安装横幅,但它与主屏幕中的内容重叠。 在主屏幕上有很多内容,并且有滚动。
有人知道为什么吗? 谢谢。
XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidsam="http://schemas.android.com/apk/res/com.jameselsey"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/home_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout <!-- CONTENT LAYOUT HERE -->
android:id="@+id/flContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
<!-- Put all your application views here, such as buttons, textviews, edittexts and so on -->
</LinearLayout>
<LinearLayout
android:id="@+id/ad_layout" <!-- AdMob LAYOUT -->
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/home_layout"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
MainActivity.java
// Create an ad.
adView = new AdView(context);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(AD_UNIT_ID);
// Add the AdView to the view hierarchy. The view
// will have no size
// until the ad is loaded.
LinearLayout layout = (LinearLayout) findViewById(R.id.ad_layout);
layout.getBottom();
layout.addView(adView);
// Create an ad request. Check logcat output for the
// hashed device ID to
// get test ads on a physical device.
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("INSERT_YOUR_HASHED_DEVICE_ID_HERE").build();
// Start loading the ad in the background.
adView.loadAd(adRequest);
【问题讨论】:
标签: android xml android-layout admob android-linearlayout