如何在横向模式下垂直展示admob广告? (安卓)
我想展示如下所示的 admob 广告。我的游戏锁定为横向模式,我想垂直显示广告。我使用 XML 布局来放置广告。
I want to show the admob ads like the following. My game is locked in landscape mode, and I want to show the ads vertically. I used the XML layout to placed my ads.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,您必须创建一个扩展 AdMob 视图的自定义
View
,然后重写onDraw()
方法。然而,因为 AdMob 视图没有可用的源代码(据我所知),这可能是不可能的。如果您有 AdMobonDraw()
方法的源代码,那么这可能只是交换 x 和 y 变量的问题。另一种选择是将您的 Activity 保持在纵向模式,然后重写您自己的视图的
onDraw()
方法以横向绘制它。但这将是一项繁重的工作,因为您必须为按钮、图像布局等创建自己的自定义视图。To do this, you would have to create a custom
View
that extends the AdMob View, then override theonDraw()
method. Because there is no source code available for the AdMob View (that I know of), however, this may be impossible. If you had the source of the AdMobonDraw()
method, it could be simply an issue of swapping the x and y variables.Another option is to keep your Activity in Portait mode, and then override your own Views'
onDraw()
method to draw it in landscape. This would be a lot of work though, as you'd have to create your own custom views for buttons, image layouts, etc.