Why is my TextField so small on the screen when targeting Android?

3

Read that the default size should be 12px. Is this something about DPI? How to solve?

enter image description here

EDIT
Thank you folks, but this doesn't seams to be something related to the font size. It looks like its something about handling DPI because it happens with simple Sprites too and weirdly the colors on Android seams to use an inversed RGB sequence 🤔

enter image description here

The Main.hx:

package;

import openfl.display.DisplayObjectContainer;
import openfl.display.Sprite;
import openfl.display.StageAlign;
import openfl.display.StageScaleMode;
import openfl.events.Event;
import openfl.system.Capabilities;
import openfl.text.TextField;
import ru.stablex.ui.UIBuilder;

class Main extends Sprite
{   
    private var size: Float = 100;

    private var r: Sprite;
    private var g: Sprite;
    private var b: Sprite;

    public function new()
    {
        super();        
        addEventListener(Event.ADDED_TO_STAGE, addedToStage, false, 0, true);
    }

    private function addedToStage(event: Event): Void
    {
        stage.scaleMode = StageScaleMode.NO_SCALE;
        stage.align = StageAlign.TOP_LEFT;

        r = createSquare(this, 0x00FF0000, size);
        g = createSquare(this, 0x0000FF00, size);
        b = createSquare(this, 0x000000FF, size);

        stage.addEventListener(Event.RESIZE, resize, false, 0, true);
        resize(null);
    }

    private function resize(event: Event): Void
    {
        r.x = 0;
        r.y = 0;

        g.x = (stage.stageWidth / 2) - (size / 2);
        g.y = (stage.stageHeight / 2) - (size / 2);

        b.x = stage.stageWidth - size;
        b.y = stage.stageHeight - size;
    }

    private function createSquare(parent: DisplayObjectContainer, color: Int, size: Float): Sprite
    {
        var box: Sprite = new Sprite();

        box.graphics.beginFill(color);
        box.graphics.drawRect(0, 0, size, size);
        box.graphics.endFill();

        parent.addChild(box);

        return box;
    }
}
android
actionscript-3
flash
haxe
openfl
asked on Stack Overflow Aug 13, 2017 by Leo Cavalcante • edited Aug 13, 2017 by Leo Cavalcante

2 Answers

2

You can use sp size unit, which always seems the same size on different dpi screens.

answered on Stack Overflow Aug 13, 2017 by Ray Wang
2

Please try this.

 text.autoSize = "center";

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextFieldAutoSize.html

You can size Sprite size to 100%.

Auto size text field with Actionscript 3 -- This link can help you.

answered on Stack Overflow Aug 13, 2017 by Uddhav Gautam • edited Aug 13, 2017 by Uddhav Gautam

User contributions licensed under CC BY-SA 3.0