【发布时间】:2017-07-30 22:34:48
【问题描述】:
我想在我的 android 音乐播放器的弹出播放器之后添加一个横幅。在 Android Studio 预览模式下,我没有错误,它运行良好,但没有显示横幅。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="320dp"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1.0">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primary"
android:paddingBottom="5dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="20dp">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:maxLines="5"
android:textColor="@color/white"
android:textSize="@dimen/text_medium"
tools:text="Mr.Afghani" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/name"
android:gravity="center_vertical">
<ImageView
android:id="@+id/play"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:src="@mipmap/play" />
<ImageView
android:id="@+id/pause"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:src="@mipmap/pause"
android:visibility="gone" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:paddingEnd="10dp"
android:paddingRight="10dp">
<SeekBar
android:id="@+id/media_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
<TextView
android:id="@+id/playback_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|top"
android:ellipsize="end"
android:textColor="@color/white"
android:textSize="11sp"
tools:text="00:00" />
</FrameLayout>
</LinearLayout>
</RelativeLayout>
<com.google.android.gms.ads.AdView
android:id="@id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="@string/bannerAd1" />
</LinearLayout>
我想在 mainActivity 中我的代码是正确的,因为我尝试将横幅放在其他屏幕上并且效果很好。有什么办法可以在弹出屏幕中放置横幅?
我在 MainActivity 中的代码是:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
init();
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest request = new AdRequest.Builder().build();
mAdView.loadAd(request);
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-1234");
AdRequest adRequest = new AdRequest.Builder().build();
mInterstitialAd.loadAd(adRequest);
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
AdRequest adRequest1 = new AdRequest.Builder().build();
mInterstitialAd.loadAd(adRequest1);
}
});
【问题讨论】:
标签: android popup admob adsense banner