• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

DPI's on Android

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,414
Can someone please explain how CX handles different resolutions and DPI's on Android devices?

As I understand, when you start a CX application on Android, CX will present you with a fullscreen to work with.
You are then supposed to read the true pixel native width and height (without having DPI modes come in-between, that could in theory give you some lower number, right?) After this is done, you have to decide what to do with these numbers and how you want to scale things appropriately.

I think I understood that part correctly but how do you get the DPI-level that is used on a particular Android device?
Are you meant to calculate the DPI for yourself depending on the native true pixel resolution that is given you using the height and width commands?
 
What do you need the DPI for? How would you approach scaling your content with it?
I am pretty happy with just scaling the same content to fill the screen. The only thing that took me some time was to get the best compromise regarding the x-y ratio.
If I could choose a metric for different screen resolutions I would like something like an average view angle or a screen diameter to average distance ratio.
 
I am basically just afraid that Retina or something similar on Android will get me in trouble later on.
Are you saying that as long as you do not use native UI one will never get into trouble in screen area?

Will you always get the correct width & height in pixels back? Or are there special cases that you need to know about?
 
Are you saying that as long as you do not use native UI one will never get into trouble in screen area?
As I see it this was the goal. But you know, targets are changing and there were allways some issues that needed to be fixed.

Will you always get the correct width & height in pixels back? Or are there special cases that you need to know about?
There was something about Android on some devices if I remember correctly were the screen resolution was scaled down for performance/energy reasons I guess.
But the content was still scaled to the whole screen area resulting in a smaller DPI value.
 
I remember a lot of people had problems with the resolution on some Android devices, and I wonder if it was related to DPI, I would think so.

If so I might (not sure though) have found a solution. You simply add this line to the MANIFEST to disable pre-scaling.
This stops you from getting the wrong screen-size If the density is more than 1 I think.

<supports-screens android:anyDensity="true" />

like so :

XML:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="...."
android:versionCode="1"
android:versionName="1.0">
<supports-screens android:anyDensity="true" />  
<application android:label="@string/app_name" >
 
Back
Top Bottom