Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I find out width of screen programmatically in android app? [duplicate]

Can I find out the width of screen programmatically in android app? I need to paint canvas but its width should be almost like screen and I could not set match_parent in java part program.

like image 372
Damir Avatar asked Dec 02 '22 01:12

Damir


1 Answers

You can get default Display instance and then read width/height from it:

int width = getWindowManager().getDefaultDisplay().getWidth();
int height = getWindowManager().getDefaultDisplay().getHeight();
like image 65
inazaruk Avatar answered Dec 19 '22 14:12

inazaruk