如何在横向模式下垂直显示admob广告?(安卓)

How to show admob ads vertical in landscape mode? (Android)(如何在横向模式下垂直显示admob广告?(安卓))
本文介绍了如何在横向模式下垂直显示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.

推荐答案

为此,您必须创建一个扩展 AdMob 视图的自定义 View,然后覆盖 onDraw() 方法.但是,由于没有可用于 AdMob 视图的源代码(据我所知),这可能是不可能的.如果您有 AdMob onDraw() 方法的来源,则可能只是交换 x 和 y 变量的问题.

To do this, you would have to create a custom View that extends the AdMob View, then override the onDraw() 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 AdMob onDraw() method, it could be simply an issue of swapping the x and y variables.

另一种选择是将您的 Activity 保持在 Portait 模式,然后覆盖您自己的 Views 的 onDraw() 方法以横向绘制它.但这将是很多工作,因为您必须为按钮、图像布局等创建自己的自定义视图.

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.

这篇关于如何在横向模式下垂直显示admob广告?(安卓)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

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

相关文档推荐

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)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)