Recent

Author Topic: Android App elements all in top left corner  (Read 1088 times)

pdhcentral

  • Newbie
  • Posts: 4
Android App elements all in top left corner
« on: September 03, 2020, 10:11:33 pm »
Hi, I can build an Android app and it installs fine. The elements, like buttons, text, etc are all on top of one another in the top left corner of the screen. I've tried different form sizes in lazarus but not really sure what else to try.

Any ideas?

Android 10, using OpenJDK and latest Laz4Android and Lazarus.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1787
Re: Android App elements all in top left corner
« Reply #1 on: September 03, 2020, 10:32:21 pm »
From docs:

https://github.com/jmpessoa/lazandroidmodulewizard/blob/master/LAMW_Getting_Started.txt


FAQ 2]: [Thanks to Ahmad Bohloolbandi (a.k.a. @developing) ]

#Question: How do we can design a layout that shown same in real device?

[Answer]: You should use the component properties:

      "Anchor",
      "PosRelativeToParent",
      "PosRelativeToAnchor",
      "LayoutParamHeight",
      "LayoutParamWhidth"
         
Example:

1-Put a "jTextView" component on your AndroidModule form:

   Set "PosRelativeToParent"
      "rpCenterHorizontal" [True]
      "rpTop" [True]

2-Put a "jButton" component on AndroidModule form:

   Set "Anchor" to "jTextView" (Because you should set position relative with "jTextView")
   set "PosRelativeToAnchor"
      "raBelow" [True]

3-Put a "jEditText" component on form:

   Set "Anchor" to "jButton".
   Set "PosRelativeToAnchor"
      "raBelow" [True]

NOTE:    Anchor setting is most important section of this design,
   because your component position depends on this property.
   And for change width and/or height of each components you should
   change/configure "LayoutParamWhidth" and/or "LayoutParamHeight".
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

shyub

  • New Member
  • *
  • Posts: 38
Re: Android App elements all in top left corner
« Reply #2 on: September 04, 2020, 10:04:13 am »
And what to do if you need to place horizontally 3 buttons of the same size and so that when you change the screen resolution, they retain their proportions?
When should you use the "LayoutParamWidth = lpMatchParent" property?
When should you use the "PosRelativeToAnchor / raToStartOf = true" property?
How to make a round button with a picture so that the proportions of the picture are not disturbed when the screen size is changed?
Thank.

Handoko

  • Hero Member
  • *****
  • Posts: 4081
  • My goal: build my own game engine using Lazarus
Re: Android App elements all in top left corner
« Reply #3 on: September 04, 2020, 11:00:49 am »
LAMW is only a tool to connect Lazarus with Android API. You will get better information if you search how the API works on Android documentation.

LayoutParamWidth = lpMatchParent means the component width is the the same as its parent. Which is useful if you want to make the component full width. For example you want the screen to have 2 buttons: yes and no. And you want to put the no button right below the yes and both of them are as wide as the screen.

I found this videos maybe useful to you:
https://www.youtube.com/watch?v=gkh-5pmYEa0
https://www.youtube.com/watch?v=X9LSVmh9KGY

To me, the easiest way to understand it is to try to set the value, compile, run and see the result myself.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1787
Re: Android App elements all in top left corner
« Reply #4 on: September 04, 2020, 08:04:24 pm »


LAMW will try retain their proportions for you!

Can you put here a screen "sketch/draft"  figure?
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

shyub

  • New Member
  • *
  • Posts: 38
Re: Android App elements all in top left corner
« Reply #5 on: September 04, 2020, 09:14:06 pm »
I want to make a cutting machine that can be controlled by Bluetooth from a tablet or phone. Here is a sketch of the appearance.

shyub

  • New Member
  • *
  • Posts: 38
Re: Android App elements all in top left corner
« Reply #6 on: September 04, 2020, 09:28:37 pm »
I have already done something similar on Lazarus + OpenGL, but under Windows. Now I want to try to make something easier on Android.

shyub

  • New Member
  • *
  • Posts: 38
Re: Android App elements all in top left corner
« Reply #7 on: September 04, 2020, 09:37:10 pm »
I found an article on component binding on the Russian domain:
https://ru-code-android.livejournal.com/4327.html

jmpessoa

  • Hero Member
  • *****
  • Posts: 1787
Re: Android App elements all in top left corner
« Reply #8 on: September 05, 2020, 05:21:24 am »

A simple example [attachment] and screenshot....

Now you have a start point....

Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

shyub

  • New Member
  • *
  • Posts: 38
Re: Android App elements all in top left corner
« Reply #9 on: September 05, 2020, 05:32:26 pm »
Спасибо за AppCuttingMachineSketch1!
Многое стало ясно.
Однако при построении примера, а также других, где jImageBtn используется при построении проекта, возникает ошибка.
Я пробовал строить с Ant и Grable вместе с:
- android-ndk-r14b, android-ndk-r18b, android-ndk-r21d;
- android-sdk_r24.4.1, android-sdk_r25.2.5, android-sdk_26-1-1;
- apache-ant-1.9.14, apache-ant-1.9.15, apache-ant-1.10.8;
- gradle-4.4.1;
Переустановил lazandroidmodulewizard-master.
Операционная система - Windows-7x86.
Среда - laz4android2.0.0-FPC3.0.4.
Что еще можно сделать?
Есть ли смысл переустанавливать Windows и использовать lazarus-2.0.10-fpc-3.2.0-win32?

shyub

  • New Member
  • *
  • Posts: 38
Re: Android App elements all in top left corner
« Reply #10 on: September 05, 2020, 05:34:14 pm »
Ant

jmpessoa

  • Hero Member
  • *****
  • Posts: 1787
Re: Android App elements all in top left corner
« Reply #11 on: September 05, 2020, 07:01:55 pm »

Please, update your LAMW from github....

(your "Controls.java"  is missing "pOnUp" native method need by jImageBtn )
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

shyub

  • New Member
  • *
  • Posts: 38
Re: Android App elements all in top left corner
« Reply #12 on: September 05, 2020, 08:39:06 pm »
Thank you so much jmpessoa!
Everything worked out.

 

TinyPortal © 2005-2018