如何在Andengine游戏活动中使用原生Textview(View)

Rai*_*Rai 5 android arabic textview andengine

我想知道有没有办法TextView在BaseAndEngine中使用原生或任何其他Android布局Activity.

我的应用程序使用Andengine作为其整个屏幕之一.此屏幕从BaseAndEngine扩展,我需要在该屏幕内使用一些本机视图,如textview.因为Andengine对阿拉伯语文本不起作用,我需要在游戏画面上显示一些阿拉伯语文本.

或者如果可能的话,如何在Andengine中以可更改的文本显示阿拉伯文本.由于可变文本以相反的顺序从左到右书写阿拉伯语.

Jon*_*ong 4

当然可以。

检查一下这段代码 - 基本上你覆盖了onSetContentView,然后你可以设置任何你想要的。

@Override
protected void onSetContentView() {
    final FrameLayout frameLayout = new FrameLayout(this);
    final FrameLayout.LayoutParams frameLayoutLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT);

    this.mRenderSurfaceView = new RenderSurfaceView(this);
    mRenderSurfaceView.setRenderer(mEngine);
    final FrameLayout.LayoutParams surfaceViewLayoutParams = new FrameLayout.LayoutParams(super.createSurfaceViewLayoutParams());
    frameLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);

    //Create any other views you want here, and add them to the frameLayout.

    this.setContentView(frameLayout, frameLayoutLayoutParams);
}
Run Code Online (Sandbox Code Playgroud)

(此方法适用于您的 的子类BaseGameActivity。)

你也可以通过xml来实现,但我认为这种方法更清晰。