for some reason, the application when reading the screen size getRealSize () began to give unreal sizes and 25 % less. I have a screen of 1920*1080, and gives 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
Code:
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
System.out.println("Screen Width: " + screenSize.getWidth());
System.out.println("Screen Height: " + screenSize.getHeight());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.