Scaling to full screen / specific resolution

garret

New member
Joined
Jun 12, 2020
Messages
14
Hi,
I’m working on a career app at the moment where you can take some tests. I learned Blitz Basic once and Cerberus seemed to be the faster way to program it instead of learning Java etc. :D
The building to HTML 5 and Android (after some troubles) works so far.

For HTML5, I've set the resolution to 1080 x 1920 by editing the config file. Works.

To my shame, I don't use a bitmap font, instead I saved all the buttons and answer texts in .png files (which I edit with Word and Paint). Originally, I just wanted to do a showcase, meanwhile I thought about coding the whole app by myself.
My thought/hope was that the phones would scale everything to the resolution I set automatically, so right now the positions of the buttons are hard-coded.

I copied the whole android build folder and installed the app on this three phones:
1.) Samsung Galaxy A7 (2017)
2.) Samsung Galaxy S6 edge
3.) Samsung SM-G357FZ (pretty old one)

Number 2, the S6, works fine, everything is scaled to 1080x1920 (but maybe it's just because that's the original resolution by luck).
On the old phone, the App doesn't start, which isn't tragic right now.

But on the A7, the resolution is set to 810 x 1571 which I can't explain. It should at least be 1080 x 2220 because that's the original resolution of the A7 as far as i know.
Question 1: Where can I set the resolution for Android? Is using a canvas the right way (which I'm not at the moment)?

Second question is, on both phones (A7 and S6), the app screen doesn't turn off (like usually after some time to save energy). It just stays on the whole time. Do you know why? :)

And a third question: My whole android-build folder is now about 30 MB. Do I need all of this when uploading to Play Store?

Greetings
Benny
 
Last edited:

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,815
Hi Benny, welcome.

do you use Mojo or Mojo2? Which CX release?

The screen resolution of the S6 i 2560x1440 pixel . The A7 (2017) runs 1920x1080. Not sure where you got your numbers from.

Do you use DeviceHeight and DeviceWidth to return the numbers?

Question 1: If you use mojo2 you HAVE TO use at least one Canvas. In mojo there is no canvas object. So I am confused what you are doing. Are you using a 3rd party framework? Are you using CX at all or some other tool?

Question 2: Usually this is done by changing the main.xml file. CX is mainly a game development tool, so we have a setting there to prevent the screen from going asleep:
1591965967976.png

1591965989242.png


Question 3: You just need the apk file that was created.
 

garret

New member
Joined
Jun 12, 2020
Messages
14
Hey Mike,
thanks for the quick answer and the warm welcome!

Do you use DeviceHeight and DeviceWidth to return the numbers?

Yes, that's where I got the resolutions from. I let them be displayed with DrawText.


If you use mojo2 you HAVE TO use at least one Canvas. In mojo there is no canvas object. So I am confused what you are doing. Are you using a 3rd party framework? Are you using CX at all or some other tool?

I only use Cerberus X and mojo, latest release as far as I know (2020-05-09b). Freshly downloaded Android Studio, SDK and Java. I didn't set any graphics or canvasses in the code. If you need, I can provide the code, but shouldn't it be something that can be fixed in the target folders like with HTML5?
I just tried to edit the main.xml file in my Cerberus (Program Files...target) folder and in the res\layout-folder you've shown, but after releasing the app they are set to the standard values again.

To your answers to question 3: Thanks!


[Edit] In case it might be useful, I store the whole project data in a Dropbox folder to have it on my notebook also.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,815
Adding to that, I am unaware of any ability to change the resolution via code from within CX.
 

garret

New member
Joined
Jun 12, 2020
Messages
14
Did you check your devices settings?

Just did. This entry doesn't seem to exist on my phone (A7, not S7!). It isn't available on all devices... By default, it's 1080x2220. Right now, I'm updating it from Android 9 to 10.

I turned off each screen zoom. The resolution 810x1571 times 1,3333 makes 1080x2560, a combination of two common sizes.


Adding to that, I am unaware of any ability to change the resolution via code from within CX.

That's something I don't understand, too. How could editing the main.xml change my already created .apk-file? Isn't this just copied from the CX folder and I'd have to change the template there?

I tried to edit some .xml-files in the Android Studio directory, because there's something about width and height they get from the "parent", but it didn't work so far.

[Edit] By the way, when I run the app and take a screenshot, its size is 1080x2220. So the question is, why is it scaled incorrectly. Maybe some window mode?
 
Last edited:

garret

New member
Joined
Jun 12, 2020
Messages
14
I kind of fixed it. I deactivated lines 5, 22 and some more because I thought I don't need them right now :rolleyes:

I get a resolution of 1080x2094 which is because of the navigation bar at the bottom, but so far I'm happy :D


Code:
Import mojo
'Android settings, defaults shown
#ANDROID_APP_LABEL="Dein Karrieretrainer"
#ANDROID_APP_PACKAGE="com.Cerberus_X.cxgame"
#ANDROID_APP_ICON=""
#ANDROID_SCREEN_ORIENTATION="user"                    '"user", "portrait", "landscape"
#ANDROID_GAMEPAD_ENABLED=False

#ANDROID_MIN_SDK_VERSION="16"
#ANDROID_TARGET_SDK_VERSION="28"
#ANDROID_BUILD_TOOLS_VERSION="28.0.3"
#ANDROID_GRADLE_VERSION="3.2.1"
#ANDROID_GRADLE_DISTRIBUTION="gradle-4.6-all.zip"
#ANDROID_REPOSITORIES=""
#ANDROID_JAVA_SOURCE_VERSION="VERSION_1_8"
#ANDROID_JAVA_TARGET_VERSION="VERSION_1_8"

#ANDROID_APPLICATION_EXTRAS=""
#ANDROID_VERSION_CODE="1"
#ANDROID_VERSION_NAME="1.0"

#ANDROID_NATIVE_GL_ENABLED=False                    'for use with the opengl modules

#rem
#ANDROID_KEY_STORE="../../release-key.keystore"
#ANDROID_KEY_ALIAS="release-key-alias"
#ANDROID_KEY_STORE_PASSWORD="password"
#ANDROID_KEY_ALIAS_PASSWORD="password"
#ANDROID_SIGN_APP=False
#end
 
Last edited:

itto

New member
Joined
Jun 8, 2020
Messages
8
Hi, how did you manage to fix the weird resolution issue exactly?

I'm having the same problem, or a very similar one.

On my Samsung Galaxy A5, I get a resolution of 1080x1920 in development mode for the Android target (debug enabled), but a resolution of 810x1440 in the production version of the APK.

Like you, also my resolution becomes 1080x1920 if multiplied by 1.3333.

Does anyone else also experience this weird behavior?

EDIT: added some more info.
 
Last edited:

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,815
So far I get the notion that it reports back the size of the view that displays the content. And the size in pixel depends on with dpi the screen has.
 

itto

New member
Joined
Jun 8, 2020
Messages
8
@MikeHart the weird thing is that it reports different values between development and release APK. Do you know anything that might cause that? Unfortunately I don't know much about Android development nor about the code that Cerberus generates.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,815
On my phone (Samsung A5 2017) it reports the same sizes (810x1440) in release and debug mode.
 

itto

New member
Joined
Jun 8, 2020
Messages
8
That's really weird.

Here are two screenshots of my game showing the release APK and the development one.

On the top right are info derived by calling DeviceWidth and DeviceHeight.

I'm not sure if you can tell by these uploaded screens, but the release one shown visibly jaggier graphics, I supposed due to the lower resolution.

EDIT: The screenshots were taken directly from the phone, and they are 1080x1920, the correct phone's resolution. Which means that somehow the game is running at a lower resolution than the screen one.

EDIT2: Relevant question asked on SO https://stackoverflow.com/q/55781498/701879
 

Attachments

  • Screenshot_20200618-222138.jpg
    Screenshot_20200618-222138.jpg
    417.4 KB · Views: 49
  • Screenshot_20200618-222312.jpg
    Screenshot_20200618-222312.jpg
    410 KB · Views: 49
Last edited:

itto

New member
Joined
Jun 8, 2020
Messages
8
Wow that would explain it, I'd never thought the OS could scale down stuff just because.

That was very insightful, thank you. This really made me scratch my head!
 

SLotman

Active member
3rd Party Module Dev
Joined
Jul 3, 2017
Messages
149
I don't know about gradle and newer APIs, but in older Monkey I have this in my manifest:

code_language.cerberus:
    <supports-screens android:smallScreens="true"
                      android:normalScreens="true"
                      android:largeScreens="true"
                      android:xlargeScreens="true"
                      android:anyDensity="true"/>

Also on the activity theme:
Code:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

There is also something about a 'full screen app' here, maybe it could help?

The problem, I think, is there are now a lot of devices with no real 'back/home' buttons, they're on screen all the time. Maybe that's why the reported resolution on the final APK is reduced? Because of the space used by those virtual buttons?
 
Last edited:

garret

New member
Joined
Jun 12, 2020
Messages
14
Hi, how did you manage to fix the weird resolution issue exactly?

On my Samsung Galaxy A5, I get a resolution of 1080x1920 in development mode for the Android target (debug enabled), but a resolution of 810x1440 in the production version of the APK.

Like you, also my resolution becomes 1080x1920 if multiplied by 1.3333.

Does anyone else also experience this weird behavior?


First, I had the Android settings commented out, because I thought I didn't need them. After letting them activated, the second phone (Samsung S6) used the full screen resolution of 1440x2560.

I solved it by using a scaling variable. For the webapp, I set a resolution of 1080x1920. To get the scaling for other resolutions, I take DeviceWidth() / 1080. I didn't scale the Height because I wanted to use a 9:16 resolution. Even my A7 has a weird resolution ratio (8,9:15,8 or something like that), so I use 9:16 and let the 300 pixels difference (1080x1920 to 1080x2220) be filled with white space and the logo. If I used a scaling for the Height, it would lose the 1:1 scaling, 'cause I would get 1.33333 for ScalingX and 1.555 for ScalingY.

Than I scale every image / button with this factor: DrawImage example, xpos*ScalingX, ypos*ScalingX, 0, ScalingX, ScalingX

Code:
        GraphicsWidth = DeviceWidth()
        GraphicsHeight = DeviceHeight()   
        ScalingX = Float(GraphicsWidth) / 1080
 
Last edited:

Tom King

New member
Joined
Apr 2, 2018
Messages
5
this might not help, but back in the days of Monkey, there was a 3rd party module called autofit which helped with the fact that different devices have different display resolutions. Apologies if this isn't what you are looking for..
 
Top Bottom