I am taking an image and drawing it to the screen using canvas. I want to scale it based on the screen size.
This is what I tried, but it cuts off a large chunk of the
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
int width = metrics.widthPixels;
int height = metrics.heightPixels;
If you get your width and height like this, you aren't going to take the size of any toolbar/status bar/navigation bar into account.
If you are coding an app that has a View
, inflate a layout with an ImageView
that is full size (i.e. match_parent
), then use the scaleType
to scale/fit/crop the image how you want.