请注意,默认大小应为12px。这是关于DPI的吗?怎么解决?
修改
谢谢大家,但这不会成为与字体大小相关的东西。看起来它是关于处理DPI的东西,因为它发生在简单的Sprite
s上,奇怪的是,Android接缝上的颜色使用反转的RGB序列
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;
}
}
答案 0 :(得分:2)
您可以使用sp
尺寸单位,在不同的dpi屏幕上看起来大小相同。
答案 1 :(得分:2)
请试试这个。
text.autoSize = "center";
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextFieldAutoSize.html
您可以将Sprite
尺寸调整为100%。
Auto size text field with Actionscript 3 - 此链接可以为您提供帮助。