user3599700
user3599700

Reputation: 31

Admob banner steals focus

I'm having some trouble with my Admob banners. Whenever I add two banners in one activity, sometimes the second banner (which is usually at the bottom of the screen) 'steals' focus. This way the user has to scroll all the way up to start reading the text. I tried all the possibilities with focusable etc., but none of them seem to work. I followed the instructions on the android developer pages (which are very clear and easy to follow) so I doubt if it's useful to post any code here. The code works so I don't get any errors that I can post here...

By the way: it is allowed to add two banners in one activity as long as they're not visible at the same time...

Any help would be appreciated...

Thanks!

Upvotes: 2

Views: 1334

Answers (4)

Ranjithkumar
Ranjithkumar

Reputation: 18406

Just add this tag in your root layout.. One line enough for fix this

android:descendantFocusability="blocksDescendants"

Upvotes: 11

Sam Lu
Sam Lu

Reputation: 3506

@android solution may not work for a native express ad. A complete solution is you should also traverse all children of adView and call setFocusable(false) for each child view before you call adView.setVisibility(View.VISIBLE).

Upvotes: 0

android
android

Reputation: 163

On onCreate() set the visibility of adview to GONE

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

    .........

    adView.setVisibility(View.GONE)

   ..........

}

After that when ad is loaded set its visibility to VISIBLE

adView.setAdListener(new AdListener() {
    @Override
    public void onAdLoaded() {
        super.onAdLoaded();

        adView.setVisibility(View.VISIBLE)
    }
});

Hope this helps ;)

Upvotes: 2

RedBrogdon
RedBrogdon

Reputation: 5351

The above comment from William is correct. AdMob recommends that banners be placed outside scrolling content areas, which means you'll only need one at a time. You can see the AdMob Banner Guidance page for more information on this.

I'm curious where you read "If the page scrolls, only one ad should be visible on the screen at a time, and, according to the AdSense program policies, publishers may place no more than 3 ad units on one entire page." It sounds like you may have mistaken some of the AdSense documentation for AdMob docs. If not, please let me know where you read that information.

Upvotes: 1

Related Questions