Libgdx Scene2d - 集演员(文本字段)填充? [英] Libgdx Scene2d - Set actor ( TextField ) padding?
本文介绍了Libgdx Scene2d - 集演员(文本字段)填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直有麻烦设置填充或相似的演员东西。无法弄清楚的方式。我想我必须在皮肤可能添加的东西?
i have been having trouble setting padding or something similar to an actor. Cant figure out the way. I guess that I must add something in the skin maybe?
我有这样的文本字段:
textboxskin = new Skin();
textboxskin.add("textfieldback", new Texture("data/textfieldback.png"));
textboxskin.add("cursor", new Texture("data/cursortextfield.png"));
textboxskin.add("selection", new Texture("data/selection.png"));
textboxskin.add("font", font);
TextFieldStyle textfieldstyle = new TextFieldStyle();
textfieldstyle.background= textboxskin.getDrawable("textfieldback");
textfieldstyle.disabledFontColor=Color.BLACK;
textfieldstyle.font=textboxskin.getFont("font");
textfieldstyle.fontColor=Color.WHITE;
textfieldstyle.cursor=textboxskin.getDrawable("cursor");
textfieldstyle.selection=textboxskin.getDrawable("selection");
textfieldusername = new TextField("username", textfieldstyle);
看起来像这样:
正如你可以看到它看起来可怕左心......
As you can see it looks horrible left centered...
推荐答案
使用Table类铺陈scene2d用户界面。要设置表:
Use the Table class to lay out scene2d UIs. To set up the Table:
stage = new Stage();
Table table = new Table();
table.setFillParent(true);
stage.addActor(table);
table.add(textFieldUsername).padBottom(20f); //also use padTop, padLeft, and padRight
table.row();
在主循环中,调用
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
有关表的详细信息,请参阅:的http:// code .google.com / p /表格的布局/
For more information on tables, see: http://code.google.com/p/table-layout/
这篇关于Libgdx Scene2d - 集演员(文本字段)填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文