如何在安卓的画布中获得屏幕尺寸的大小?[英] How to get the size of the screen size in a canvas in android?

本文是小编为大家收集整理的关于如何在安卓的画布中获得屏幕尺寸的大小?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我能够在正常活动中获取屏幕尺寸,但我需要在画布视图和操作中获取屏幕大小并按照它操作.Antal上它会有所帮助.谢谢.

推荐答案

我得到了ridgepixels高度pixels使用它.

DisplayMetrics metrics = getBaseContext().getResources().getDisplayMetrics();         
  int w = metrics.widthPixels;
  int h = metrics.heightPixels;

本文地址:https://www.itbaoku.cn/post/102352.html

问题描述

I am able to get the screen size in the normal activity but I need to get the screen size in a canvas view & manipulate in accordance with it.Any snippet on it will be helpful.Thanks.

推荐答案

i got widthPixels heightPixels use ing this.

DisplayMetrics metrics = getBaseContext().getResources().getDisplayMetrics();         
  int w = metrics.widthPixels;
  int h = metrics.heightPixels;