Libgdx Scene2d - Set actor ( TextField ) padding?(Libgdx Scene2d - 设置演员( TextField )填充?)
问题描述
我在设置填充或类似于演员的东西时遇到了问题.想不通办法.我想我可能必须在皮肤中添加一些东西?
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 UI.设置表格:
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/table-layout/
For more information on tables, see: http://code.google.com/p/table-layout/
这篇关于Libgdx Scene2d - 设置演员( TextField )填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Libgdx Scene2d - 设置演员( TextField )填充?


基础教程推荐
- iOS4 创建后台定时器 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01