Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the size of the screen size in a canvas in android?

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.

like image 368
Karthik Avatar asked Dec 19 '25 23:12

Karthik


1 Answers

i got widthPixels heightPixels use ing this.

DisplayMetrics metrics = getBaseContext().getResources().getDisplayMetrics();         
  int w = metrics.widthPixels;
  int h = metrics.heightPixels;
like image 104
NagarjunaReddy Avatar answered Dec 21 '25 12:12

NagarjunaReddy