根据http://android-developers.blogspot.ca/2013/09/using-hardware-scaler-for-performance.html,我正在尝试使用 setFixedSize 在屏幕尺寸非常大的平板电脑上加速游戏
我遇到的问题是我目前有一个将 Surface 添加到的 RelativeLayout。
作为测试用例,我采用 gl2jni NDK 示例应用程序,并在 init 方法中将 getHolder().setFixedSize(128,128) 调用添加到 GJ2JNIView.java 中。这正确地创建了一个丑陋的 128x128 缓冲区,该缓冲区被放大到全屏并且完全按照我的预期工作。
然后我修改了JL2JNIActivity中的onCreate方法如下。
@Override protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
mView = new GL2JNIView(getApplication());
boolean useRelativeLayout = false;
if ( useRelativeLayout ) {
mLayout = new RelativeLayout(this);
RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
mLayout.setLayoutParams(param);
mLayout.addView(mView);
setContentView(mLayout);
} else {
setContentView(mView);
}
}
当我将 useRelativeLayout 设置为 false,并且 setContentView 直接使用我的称为 setFixed 大小的 GL2JNIView 时,它按预期工作。
当我将 useRelativeLayout 设置为 true 时,它会将 mView 显示为左上角的一个 128x128 小缓冲区。