android – Libgdx Scene2d – 设置actor(TextField)填充?

我一直无法设置填充或类似于演员的东西.无法弄明白的方式.我想我必须在皮肤上添加一些东西吗?

我有这个TextField:

        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);

看起来像这样:

你可以看到它看起来很可怕左中心…

最佳答案
使用Table类来布局scene2d UI.要设置表:

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/

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...