How to get screen width and height? lazarus / 43-Android ---------------------------------------------------------------------- bmcsoft · 2021-06-24 15:18 Hello, we need to obtain screen width and height, depending on the rotation of the device. I've found such code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Display display = getWindowManager().getDefaultDisplay(); int width = display.getWidth();int height = display.getHeight();and newest variant: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i DisplayMetrics metrics = new DisplayMetrics();getWindowManager().getDe faultDisplay().getMetrics(metrics);int height = metrics.heightPixels;int width = metrics.widthPixels;Anybody help to translate it in Lazarus code and post result code in this topic. ---------------------------------------------------------------------- Bart · 2021-06-24 16:53 Screen.Width and Screen.Heigth don't work on Android? Bart ---------------------------------------------------------------------- loaded · 2021-06-24 17:25 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TAndroidModule1.jButton1Click(Sender: TObject);begin  showmessage(intt ostr(GetRealScreenWidth())+'x'+inttostr(GetRealScreenHeight()));end;  Quote from: Bart on June 24, 2021, 06:53:57 pmScreen.Width and Screen.Heigth don't work on Android? Bart No it doesn't work. ---------------------------------------------------------------------- Bart · 2021-06-24 17:41 Quote from: loaded on June 24, 2021, 07:25:47 pmQuote from: Bart on June 24, 2021, 06:53:57 pmScreen.Width and Screen.Heigth don't work on Android? Bart No it doesn't work. Sounds like a bug to me? Bart ---------------------------------------------------------------------- loaded · 2021-06-24 18:04 It's not a bug, LAMW does not use LCL. It cannot be used in Screen.Width because it is defined in the forms unit (LCL). If I'm wrong, someone who knows better can clarify. ---------------------------------------------------------------------- Bart · 2021-06-24 18:07 OK, then I simply misunderstood. (It will come as no surprise to you that I don't do android programming.) Bart ---------------------------------------------------------------------- jmpessoa · 2021-06-24 21:04 Quote I don't do android programming.... But you can!! About rotation,  you can start with demo "AppPanelRotateDemo1" and "AppCameraDemo" ---------------------------------------------------------------------- bmcsoft · 2021-06-25 05:18 Quote from: jmpessoa on June 24, 2021, 11:04:36 pmQuote I don't do android programming.... But you can!! All we can. But if this elementary operation has not received a solution, then what can we talk about. ---------------------------------------------------------------------- bmcsoft · 2021-06-25 05:20 Quote from: loaded on June 24, 2021, 08:04:51 pmIt's not a bug, LAMW does not use LCL. It cannot be used in Screen.Width because it is defined in the forms unit (LCL).Yes, I need to get screen resolution in LAMW. ---------------------------------------------------------------------- loaded · 2021-06-25 06:18 You must have overlooked it, The method you should use for Resolution; Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   GetRealScreenWidth();  GetRealScreenHeight(); ---------------------------------------------------------------------- Mongkey · 2021-06-25 14:25 The LAMW samples should cover all minimum android apps should work, and it is enough for general app development, for more advance things you should read and practice a lot, that why instant noodle are more cheaper a lot than real man made ramen ---------------------------------------------------------------------- jmpessoa · 2021-06-25 20:20 QuoteBut if this elementary operation has not received a solution, then what can we talk about..... You can get help from Lazarus smart editor.... using: Self. To access this jForm   functions/procedures..... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     procedure SetScreenOrientationStyle(_orientation: TScreenStyle);    function  GetScreenOrientationStyle(): TScreenStyle;      function  GetScreenSize(): string;    function  GetScreenDensity(): string; overload;    function  GetScreenDpi(): integer;    function  GetScreenDensity(strDensity: string): integer; overload;    procedure SetDensityAssets( _value : TDensityAssets ); // by ADiV      function  GetScreenWidth(): integer;      // by ADiV    function  GetScreenHeight(): integer;     // by ADiV    function  GetRealScreenWidth(): integer;  // by ADiV    function  GetRealScreenHeight(): integer; // by ADiV  But, remember that Android can handle these issues... If you have a good Layout design and the perfect image pixel in  the project folders   ..../res/drawable*** ---------------------------------------------------------------------- Mongkey · 2021-06-26 03:01 Quote from: bmcsoft on June 25, 2021, 07:18:35 amQuote from: jmpessoa on June 24, 2021, 11:04:36 pmQuote I don't do android programming.... But you can!! All we can. But if this elementary operation has not received a solution, then what can we talk about. I see your square game panels are 8x8, why not you placing 1/8 parent to height and width, let say you need 2 block height of your screen height for setting or seeing match result, you can do by 1/10 relatif to parent for height.  , So you not need allocate you time concerning pixel, screen resolution, let LAMW handle for u. Practice n talking to the code is the key