如何将文本视图添加到andengine中的等距平铺地图?

时间:2013-03-14 07:54:06

标签: android andengine

我想在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();
}

但它没有显示文字视图。

0 个答案:

没有答案
相关问题