I am creating a new application and I am using Canvas. I scale the canvas, but I set the size:
public static final int WIDTH = 1920; public static final int HEIGHT = 1080;
(the screen will be in the landscape, so the width is greater than the height) Value if this application is intended for portrait orientation:
public static final int WIDTH = 1080; public static final int HEIGHT = 1920;
Scaled since canvas is usually equal to:
public void render(Canvas c) { super.draw(c); final float scaleFactorX = getWidth()/(WIDTH*1.f); final float scaleFactorY = getHeight()/(HEIGHT*1.f); if (c != null) { final int savedState = c.save(); c.scale(scaleFactorX, scaleFactorY);
Most phones today are HD or better, and very few have lower resolution. But there are phones, and I'm concerned about how scaling will respond to other phones other than HD / better, as my application will achieve better resolution than the screen supports.
Any ideas how the phone will react to this? Some phones may automatically scale, but is a common feature or function just some phones?
SurfaceView is activated in Activity and set using setContentView:
@Override public void onCreate(Bundle sis){ super.onCreate(sis); CustomSurfaceView sf = new CustomSurfaceView(this); setContentView(sf);
EDIT
To clarify:
I scale the canvas to a specific size that matches the resolution of HD 1080. The HD 1080 screen will not scale compared to the screen. 2K screens will scale to HD 1080 resolution, meaning it will work at a lower resolution than the maximum screen size.
The size of the HD1080 is 1080x1920, which will be applied to the canvas on the screen, which is smaller than this size.
But how will scanning work on HD 720 screens, or even worse than HD 1080? The application will push a larger size than the screen supports. How does the phone react to this?
Running the application in a nexus emulator (nexus 4, api 23) leads to the fact that the canvas is slightly pushed away from the screen. Not all phones behave like nexus, because the firmware has been edited by manufacturers, therefore, just because it is disconnected from the screen on Nexus, this does not mean that it will be on Sony or any other brand.
Note: HD refers to HD 1080 unless otherwise indicated.