如何隐藏/禁用 admob adview?

How to hide/disable admob adview?(如何隐藏/禁用 admob adview?)
本文介绍了如何隐藏/禁用 admob adview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过 view.gone 隐藏 admob adview:

I hide admob adview by view.gone:

//adView.setClickable(false);
//adView.clearFocus();
//adView.setEnabled(false);
//adView.setFilterTouchesWhenObscured(true);
//adView.setFocusable(false);
//adView.setFocusableInTouchMode(false);
adView.setVisibility(View.GONE);
adView.startAnimation( animation );

这隐藏了广告,但广告视图本身仍然是可触摸的,所以如果我触摸广告视图的空间,它仍然会打开浏览器并将我重定向到广告,尽管广告本身不可见.

This hides the ad, but the adview itself is still touchable, so if I touch the adview's space, it still opens the browser and redirects me to the ad, although the ad itself is not visible.

如何也禁用触摸事件?我已经尝试了上面的所有行,但没有一个行得通.

How to disable the touch event too? I've tried all lines above but none of them worked.

有什么建议吗?

推荐答案

尝试根据需要使用 setOnTouchListener 和 Override onTouch.你也可以使用 removeView():

Try to use setOnTouchListener and Override onTouch like you want. Also you can use removeView():

LinearLayout linLay = (LinearLayout)findViewById(R.id.ad_layout);
linLay.removeView(adView); 
LinearLayout.LayoutParams params = new  LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT);
linLay.addView(adView, params);

并在需要时将其添加回来.

and add it back when you need.

这篇关于如何隐藏/禁用 admob adview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)