0

我想在andengine中为等距平铺地图游戏添加字幕,我添加了以下代码

@Override
public void onPopulateScene(Scene pScene, OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {
    relativeLayout = new RelativeLayout(this);
    relativeLayout.setId(0);
    this.addContentView(relativeLayout, new LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.FILL_PARENT));
    relativeLayout.setBackgroundColor(Color.TRANSPARENT);
    tv = new TextView(this);
    tv.setText("Actions");
    tv.setTextColor(Color.WHITE);
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT,RelativeLayout.TRUE);
    lp.setMargins(0, 200, 0, 0);
    tv.setLayoutParams(lp);
    relativeLayout.addView(tv);
    pOnPopulateSceneCallback.onPopulateSceneFinished();
}

但它不显示文本视图。

4

0 回答 0