6

パディングやアクターに似たものを設定するのに苦労しています。方法がわかりません。たぶん、スキンに何かを追加する必要があると思いますか?

私はこの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);

次のようになります。

ここに画像の説明を入力

ご覧のとおり、左中央がひどいように見えます...

4

3 に答える 3

1

ナインパッチを使用できます。これにより、テクスチャが高さと幅を定義する 9 つの「パッチ」に分割され、TextButton に指定できる NinePatchDrawable に指定されます。外側の「パッチ」は余白として機能し、微調整(激しいものではない)で見栄えがよくなり、目標を達成できると思います。

私はこの投稿からそれらについて学びました: Loading nine-patch image as a Libgdx Scene2d Button background look awesome

于 2014-01-13T21:34:06.707 に答える