AdMob的从谷歌游戏服务将执行不希望自动滚屏

AdMob的从谷歌游戏服务将执行不希望自动滚屏

本文介绍了AdMob的从谷歌游戏服务将执行不希望自动滚屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是用的AdMob从谷歌Play业务版本13.我知道,当我把在滚动型广告,AdMob的将尝试执行不希望自动滚动,它提取后成功地从服务器中的广告。

I were using AdMob from Google Play services version 13. I realize, when I place the advertisement within ScrollView, AdMob will try to perform undesired auto scrolling, after it fetches the advertisement successfully from server.

package com.example.admob_bug;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.LinearLayout;

public class MainActivity extends Activity {

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

        // Create the adView.
        adView = new AdView(this);
        adView.setAdUnitId("a151b03485063e0");
        adView.setAdSize(AdSize.BANNER);

        // Lookup your LinearLayout assuming it's been given
        // the attribute android:id="@+id/mainLayout".
        LinearLayout layout = (LinearLayout)findViewById(R.id.advertisement);

        // Add the adView to it.
        layout.addView(adView);

        // Initiate a generic request.
        AdRequest adRequest = new AdRequest.Builder().build();

        // Load the adView with the ad request.
        adView.loadAd(adRequest);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public void onPause() {
        adView.pause();
        super.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        adView.resume();
    }

    @Override
    public void onDestroy() {
        adView.destroy();
        super.onDestroy();
    }

    private AdView adView;
}

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

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

        ...
        ...

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Large Text 7"
            android:layout_margin="30dp"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <LinearLayout
            android:id="@+id/advertisement"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

        </LinearLayout>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Large Text 8"
            android:layout_margin="30dp"
            android:textAppearance="?android:attr/textAppearanceLarge" />

    </LinearLayout>

</ScrollView>

//www.dropbox:

完整的源$ C ​​$ C可从 HTTPS下载.COM / S / e53zjqsc5cnilz2 / admob_bug.zip

The complete source code can be downloaded from https://www.dropbox.com/s/e53zjqsc5cnilz2/admob_bug.zip

您会发现这个问题后,你的10秒左右(视网络质量)等待,加载广告后。

You will realize this problem, after you wait for around 10 seconds (Depending on network quality), after advertisement is loaded.

有任何解决方法,以prevent自动滚动?

Is there any workaround to prevent auto scrolling?

这个问题是不存在的,以前我是从旧的AdMob 6.4.1 JAR切换,谷歌的AdMob的播放服务。

This problem wasn't there, before I switch from old AdMob 6.4.1 JAR, to AdMob of Google Play Service.

我使用的设备的Nexus S的Andr​​oid 4.1.2测试。

I'm testing using device Nexus S, Android 4.1.2.

推荐答案

更​​新activity_main.xml

update your activity_main.xml

 <LinearLayout
        android:id="@+id/advertisement"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:descendantFocusability="blocksDescendants"
        android:orientation="vertical" >
    </LinearLayout>

这是工作的罚款。测试与纽带4和三星Galaxy s.also仿真器API 18。

it is working fine.testing with nexus 4 and samsung galaxy s.also emulator api 18.

这篇关于AdMob的从谷歌游戏服务将执行不希望自动滚屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 12:29