微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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/

原文地址:https://www.jb51.cc/android/430585.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐