- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用 andengine GLES2
开发(学习构建 :) 游戏。我正在使用 Base game activity,我覆盖了 setContent
View 来放置我的 admob 广告。
除解析策略外,一切正常。
< strong>Ratio Resolution policy 是我与 CAMERA_WIDTH = 800; 一起使用的策略;和 CAMERA_HEIGHT = 480;
问题是,无论何时被覆盖,onsetContentView
场景都不会与中心对齐,并且边距仅显示在底部而不是同时显示在顶部和底部。水平对齐时也会发生同样的情况:边距将只显示在右侧,而不是两侧。我该如何纠正这个问题?我在下面给出我的代码:
@Override
protected void onSetContentView() {
System.out.println("Content setting");
this.mRenderSurfaceView = new RenderSurfaceView(this);
final LayoutParams layoutParams = new LayoutParams(
android.view.ViewGroup.LayoutParams.MATCH_PARENT,
android.view.ViewGroup.LayoutParams.MATCH_PARENT);
layoutParams.gravity = Gravity.LEFT ;
final android.widget.FrameLayout.LayoutParams surfaceViewLayoutParams = new FrameLayout.LayoutParams(
layoutParams);
adView = new AdView(this, AdSize.BANNER, "xxxxxxxxxxxxx");
final FrameLayout.LayoutParams adViewLayoutParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.LEFT
);
final FrameLayout frameLayout = new FrameLayout(this);
final FrameLayout.LayoutParams frameLayoutLayoutParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.FILL_PARENT,
FrameLayout.LayoutParams.FILL_PARENT,Gravity.CENTER);
frameLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);
frameLayout.addView(adView, adViewLayoutParams);
this.setContentView(frameLayout, frameLayoutLayoutParams);
this.mRenderSurfaceView.setRenderer(this.mEngine, this);
}
这是我得到的图像,如果您选择该图像,您可以看到场景下方的白色边缘(由于堆栈溢出也没有引起注意,它也有白色背景)
任何建议都会对我很有帮助
我该如何解决这个问题请帮助我
感谢大家
最佳答案
已修复:
在使用布局进行游戏后,我可以解决这个问题。
现在我的表面 View 与中心对齐并且广告以所需的方式显示。
这是我的代码
@Override
protected void onSetContentView() {
final RelativeLayout relativeLayout = new RelativeLayout(this);
final FrameLayout.LayoutParams relativeLayoutLayoutParams = new FrameLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
this.mRenderSurfaceView = new RenderSurfaceView(this);
this.mRenderSurfaceView.setRenderer(this.mEngine, this);
final android.widget.RelativeLayout.LayoutParams surfaceViewLayoutParams = new RelativeLayout.LayoutParams(BaseGameActivity.createSurfaceViewLayoutParams());
surfaceViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
relativeLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);
FrameLayout frameLayout = new FrameLayout(this);
adView = new AdView(this, AdSize.BANNER, "xxxxxxx");
adView.refreshDrawableState();
frameLayout.addView(adView);
relativeLayout.addView(frameLayout);
this.setContentView(relativeLayout, relativeLayoutLayoutParams);
}
关于android - 如何在 Andengine Base 游戏 Activity 中使用 Ratio Resolution 策略时覆盖 onSetContentView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14427152/
WPF 文档和教程指出 WPF 与分辨率无关,据我所知,它会在不同分辨率(1600x1200 -> native 和 1024x768)和/或 DPI 设置下显示相同大小的窗口。但是,当我尝试示例应用
对于我的应用程序,我分析了 Kinect v2 的空间分辨率。 为了分析空间分辨率,我记录了一个垂直平面到给定距离的平面,并将平面的深度图转换为点云。然后我通过计算欧几里得距离将一个点与他的邻居进行比
有没有办法在 Android 上的 OpenGL ES 2.0 中将场景渲染为正常分辨率,然后将屏幕的另一部分渲染为较低分辨率? 如果我使用 GLES20.glViewPort() 并更改分辨率,它不
使用 CameraX.LensFacing.FRONT 时出现此错误, 在模拟器上测试 E/AndroidRuntime: FATAL EXCEPTION: main Process: met
我没有使用Firebase,这似乎是other问题的原因people 这是错误的屏幕截图: 这是我的依赖项列表: dependencies { implementation project('
我正在按照教程 (link) 将图像上传到 Firebase 数据库,但出现以下错误。我重新检查了 gradle 依赖项并启用了 multidex 支持,但错误仍然存在 java.lang.NoC
我正在尝试使用 durandal,但出现此错误: 错误: bower requirejs extra-resolution Unnecessary resolution: requirejs#~2.2
我的应用程序被苹果拒绝了,原因是“iPhone 应用程序还必须在 iPad 上运行而无需修改,iPhone 分辨率和 2X iPhone 3GS 分辨率”。Apple 建议“为了支持 iPad 3GS
我在我的网站上显示用户的gravatr图像。我怎么知道要使用的最佳高分辨率?例如哪个参数应该是“ s”。 https://secure.gravatar.com/avatar/?s=250 当然,这取
我正在开发一个网站,但我不知道“支持”的最低分辨率应该是多少。我知道它可以在所有分辨率下运行,但“支持”是指所有内容都适合页面而不需要左右滚动。我是否应该考虑“支持”1024x768? 最佳答案 除了
有谁知道ImageNet中图片的分辨率数据集? 抱歉,我在他们的网站或任何 papers 中都找不到它。 . 最佳答案 图像的尺寸和分辨率各不相同。许多应用程序将所有图像的大小调整/裁剪为 256x2
我已经陷入了这个问题:我需要使用 DPI=1200 和特定的打印尺寸来绘制图像。 默认情况下 png 看起来不错... png("test.png",width=3.25,height=3.25,un
我有一个包含 16.000 个条目的测量数组,形式为 [t] [value] 问题是我的数据记录器太慢了,我每秒只有测量点。对于我的模拟,我需要增加伪分辨率。这样每个时间步都除以 1000,每个测量值
我正在尝试使用“分辨率”媒体查询来确定屏幕的实际 DPI。 我正在做的代码是这样的: window.matchMedia(`(resolution: ${value}dpi)`).matches 但我
我正在开发一款支持多种分辨率的应用。我已经通过了http://developer.android.com/guide/practices/screens_support.html但找不到解决方案。 决
我已经从 GitHub 中提取了文件。现在我需要创建一个合并冲突。 如何在 GitHub 上故意创建合并冲突? 最佳答案 在两个分支中编辑同一行,并尝试合并 Merge conflicts in gi
有什么方法可以更改分辨率或为亚马逊 Kindle 键盘上的屏幕设置不同的边界?我的屏幕有一部分出现裂纹,我想解决这个问题。 我试过在文件系统中乱搞(通过 WiFi 连接),但我的所有属性更改都没有任何
This question already has answers here: Closed 11 years ago. Duplicate: Recommended website resoluti
Closed. This question is opinion-based。它当前不接受答案。 想改善这个问题吗?更新问题,以便editing this post用事实和引用来回答。 6年前关闭。
我在网站的几个部分中使用了 tinyscrollbar 插件。到目前为止,它运行良好。但现在由于某种原因,鼠标滚轮可以滚动,但拖放 slider 不能滚动。 我使用的分辨率是 1360x768,但我在
我是一名优秀的程序员,十分优秀!