我正在使用适用于Android的Google AdMob Ads SDK 4.0.4
默认情况下,在加载广告之前,AdView将没有大小.如果广告上方或下方有按钮,则可能会出现问题.
如果广告在他们即将点击按钮的确切时刻返回,则用户可能会意外点击该广告.
在旧的admob SDK中,我使用setGoneWithoutAd(false)解决了这个问题.这样,即使广告尚未退回,也会保留空间.
在新的SDK(Google Admob Ads SDK 4.0.4)中,我设法通过使用此快速修复程序执行相同的操作:通过将广告放入宽度为"320dp"且高度为"50dp"的某些布局来保留空间
<LinearLayout
android:layout_width="320dp"
android:layout_height="50dp" >
<com.google.ads.AdView android:id="@+id/adview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="xxxxxxxxxxx"
ads:adSize="BANNER"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
它有效,但我不确定这是否是一个正确的方法.(我会遇到着名的"没有足够的空间来展示广告!"问题吗?)
总结一个问题:即使在请求广告时,如何(正确)使AdView"占用"空间?
先感谢您!
我需要帮助在底部的GridView中添加一个空格.此空间应位于GridView的最后一个元素内部.当用户滚动到GridView的底部时,此空间不应该像下一个元素的边距一样工作,它应该只是可见的.原因是广告横幅部分覆盖了GridView的底部.除了这个障碍,用户仍然可以看到GridView的全部内容,这就是为什么需要GridView底部的空间.
left:ad(蓝色)覆盖部分GridView元素(橙色); right:ad覆盖GridView底部的空间
例如,它看起来如何,想象空间位于底部,而不是顶部.
到目前为止,我尝试使用Padding和Marging Variables for Bottom,但它们不是问题的正确变量.我还搜索了stackoverflow,我发现了一些类似的问题:在GridView或ListView的底部添加额外的空间,或者:在Android中添加页脚视图到多列GridView?.但解决方案似乎不适合我的情况,而且我在布局文件中寻找解决方案,而不是在源代码内(如果有任何当然).
非常感激您的帮忙.
在我的app委托中,我实例化一个iAd横幅并将其分配给一个委托属性,然后我加载了主View Controller.
在主视图控制器中,我将iAd横幅添加为子视图,并实例化"主菜单"视图控制器并将其视图添加为子视图.好的,现在我的应用程序有一个主菜单(使用UINavigationController
其他视图从导航堆栈中推出/弹出,将广告留在顶部).
但是,当我显示模态对话框(如发送电子邮件)并将其关闭时,iAd横幅消失了,主菜单视图现在占据整个屏幕.我需要做些什么来"刷新"顶部的iAd视图吗?
我在将横幅广告添加到我的 Android 应用程序的此布局中时遇到问题。但是这个广告没有显示。ActivityMain.java 中的实现没有问题,因为当我添加其他布局时,横幅开始显示。
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:attribute="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PlayerActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray_background"
android:orientation="vertical">
// facebook banner ad
<LinearLayout
android:id="@+id/banner_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
/>
<developer.shivam.library.CrescentoContainer
android:id="@+id/crescentoContainer"
android:layout_width="match_parent"
android:layout_height="440dp"
android:elevation="20dp"
android:scaleType="centerCrop"
attribute:curvature="50dp">
<com.flaviofaria.kenburnsview.KenBurnsView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/wallpaper" />
<com.cleveroad.play_widget.PlayLayout
android:layout_marginTop="?attr/actionBarSize"
android:id="@+id/ivPhoto"
android:layout_width="260dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
</developer.shivam.library.CrescentoContainer>
<include layout="@layout/song_info" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
我希望自动循环播放我拥有的HTML5横幅广告.动画是使用NanoTween构建的.这是JS代码:
var container = getElement("id","container");
var items = {
c1: getElement("id", "copy_1"),
c2: getElement("id", "copy_2"),
c3: getElement("id", "copy_3"),
c4: getElement("id", "copy_4"),
c5: getElement("id", "copy_5"),
c6: getElement("id", "copy_6"),
button: getElement("id", "button"),
elipseOverlay: getElement("id", "elipseOverlay"),
elipseOverlay2: getElement("id", "elipseOverlay2"),
elipse: getElement("id", "elipse"),
elipse2: getElement("id", "elipse2"),
elipseContainer: getElement("id", "elipseContainer"),
bar: getElement("id", "bar"),
magnaclick: getElement("id", "magnaclick"),
shirt: getElement("id", "shirt")
};
function init() {
setTimeout(function() {
startAnimation();
}, 5);
};
//
function startAnimation() {
container.style.visibility = "visible";
var delay = 0;
var quickerSpeed = 0.3;
var …
Run Code Online (Sandbox Code Playgroud) 将 Google Ads SDK 更新到 19.3.0 后,会为onAdFailedToLoad()
. 我该如何解决这个问题?
我的代码:
public void BannerAdMob() {
final AdView adView = findViewById(R.id.adsView);
adView.loadAd(new AdRequest.Builder().build());
adView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
}
@Override
public void onAdFailedToLoad(int error) { // this method is deprecated
}
});
}
Run Code Online (Sandbox Code Playgroud) 我用Flash创建了这个横幅,我需要点击它打开一个网页.
我使用了这个Actionscript 3.0代码......
link_btn.addEventListener(MouseEvent.CLICK, openurl);
function openurl(event:MouseEvent):void {
var url:URLRequest = new URLRequest("http://www.festivity.it");
navigateToURL(url, "_blank");
}
Run Code Online (Sandbox Code Playgroud)
但它没有用!
WHYYYYY?
我尝试在时间轴上和按钮上设置它,但没有任何改变.
每当我点击按钮......没有任何反应,但有时会打开一条带有安全警报的消息.
谢谢.
基娅拉
我在我的 React Native 应用程序中使用 expo 和 admob 实现了广告,但我想在没有加载广告时摆脱空白/阻塞空间。还没有找到任何例子。(除了横幅之外,我在该页面上有一个标题和滚动视图)。这就是 Admob 横幅的实现方式:
// Display a banner
<AdMobBanner
bannerSize="fullBanner"
adUnitID="ca-app-pub-3940256099942544/6300978111" // Test ID, Replace with your-admob-unit-id
testDeviceID="EMULATOR" />
Run Code Online (Sandbox Code Playgroud) 我尝试用AdMob制作Android应用程序.
我按照文档中的描述创建了admob adView:
FrameLayout layout = (FrameLayout) findViewById(R.id.frame_layout);
adView = new AdView(this, AdSize.SMART_BANNER, myAdMobId );
Run Code Online (Sandbox Code Playgroud)
然后,如果我在设备320x480(手机)上运行我的应用程序,广告横幅显示在顶部,但如果我在Android平板电脑1280x800上运行我的应用程序,广告横幅将显示为水平和垂直居中 - 位于屏幕的中心.
另外,我尝试了AdSize.BANNER,AdSize.IAB_BANNER,AdSize.IAB_LEADERBOARD - 结果是一样的.
我做错了什么?
UPD1.RES /布局/ main.xml中
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frame_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.mysite.myapp.GameView
android:id="@+id/game"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud) banner-ads ×9
android ×5
admob ×4
adbannerview ×2
adview ×1
expo ×1
flash ×1
html5 ×1
iad ×1
ios ×1
java ×1
javascript ×1
mobile ×1
react-native ×1
tween ×1