扫描小程序码分享
RT,小游戏的CustomAd在createCustomAd之后没办法居中,有没有在show的时候让他居中显示呢,或者在创建之前可以获取到CustomAd的宽度呢
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
使用left,top值控制偏移量即可
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
用systemInfo中的宽和高设置就不管什么机型都能居中了,如下面的代码:
const systemInfo = wx.getSystemInfoSync();
let CustomAd = wx.createCustomAd({//广告
adUnitId: '你的广告ID',
style: {
left: (systemInfo.windowWidth-350)/2,
top: systemInfo.windowHeight-280,
width: 350
}
});
觉得有帮助的就帮我玩一下我的小游戏吧:
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
使用left,top值控制偏移量即可
用systemInfo中的宽和高设置就不管什么机型都能居中了,如下面的代码:
const systemInfo = wx.getSystemInfoSync();
let CustomAd = wx.createCustomAd({//广告
adUnitId: '你的广告ID',
style: {
left: (systemInfo.windowWidth-350)/2,
top: systemInfo.windowHeight-280,
width: 350
}
});
觉得有帮助的就帮我玩一下我的小游戏吧: