1

目前我正在使用以下计算来独立计算字体比例分辨率:

fontScale = ( Gdx.graphics.getDensity() / BaseDensity ) * (( (float)Gdx.graphics.getWidth() / (float)BaseResolutionWidth ) / (Gdx.graphics.getDensity() / BaseDensity) );

我正在使用以下代码来相对于彼此定位我的字体:

font.draw(batch, glyphLayout, UniX(0.5f) - w * 0.5f, UniY(0.23f + 0.04f * scale) - h * 0.5f);

我完全糊涂了。这些文本在我的 8 英寸平板电脑上相互显示,但它们在我的手机上完全正确对齐。

我应该如何正确地独立定位这个分辨率?

4

1 回答 1

0

由于我严格在纵向模式下使用我的应用程序,因此我使用以下纵横比。这似乎可以完美地跨我的设备(手机和平板电脑)工作。

aspectRatio = ( Gdx.graphics.getHeight() / Gdx.graphics.getWidth() );
fontScale = ( ( Gdx.graphics.getDensity() / BaseDensity ) * aspectRatio );
于 2016-02-05T12:52:08.693 回答