简体   繁体   English

尺寸屏幕问题

[英]Size screen issue

for some reason, the application when reading the screen size getRealSize () began to give unreal sizes and 25 % less.出于某种原因,应用程序在读取屏幕尺寸时 getRealSize() 开始给出不真实的尺寸并减少 25%。 I have a screen of 1920*1080, and gives 1440*810.我有一个 1920*1080 的屏幕,并给出 1440*810。 When I start a project, the screen size shows correctly.当我开始一个项目时,屏幕大小显示正确。 But after the build for publication, this problem begins.但是在发布构建之后,这个问题就开始了。

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main); Point point = new Point();
    getWindowManager().getDefaultDisplay().getRealSize(point);}

You could use Dimension from Toolkit您可以使用 Toolkit 中的 Dimension

Code:代码:

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

System.out.println("Screen Width: " + screenSize.getWidth());

System.out.println("Screen Height: " + screenSize.getHeight());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM