Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我能够在正常活动中获得屏幕尺寸,但我需要在画布视图中获得屏幕尺寸并根据它进行操作。任何片段都会有所帮助。谢谢。
我得到了 widthPixels heightPixels 使用这个。
DisplayMetrics metrics = getBaseContext().getResources().getDisplayMetrics(); int w = metrics.widthPixels; int h = metrics.heightPixels;