Recent

Author Topic: LAMW: Adjust x/y  (Read 4627 times)

c4p

  • Full Member
  • ***
  • Posts: 158
LAMW: Adjust x/y
« on: August 22, 2017, 11:54:33 am »
Is there a way to resize x or y axis  on the form on smaller sized dpi phones? example: button off the end of the x axis?

Thanks.
« Last Edit: August 22, 2017, 11:56:09 am by c4p »
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: LAMW: Adjust x/y
« Reply #1 on: August 23, 2017, 02:56:18 am »

Ok, c4p.

I will try some solution....

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

c4p

  • Full Member
  • ***
  • Posts: 158
Re: LAMW: Adjust x/y
« Reply #2 on: August 23, 2017, 10:26:56 am »
I did a workaround by setting an invisible label at x 0 and entered a Text character until I reached a point I wanted (not ideal at all).
Am I correct that you can't anchor an anchor to an anchor? this would solve this issue.
I think the solution is being able to anchor a component to an already anchored component:
Example: An editbox to the right of label, this works using raAlignBaseline/raToRightOf in PosRelativeToAnchor, then being able to anchor another component to the right of that, *does not work*, resets to the top of the form but seems to be aligned with x, so y looks like it's being lost?
Basically PosRelativeToAnchor/Anchor does not seem to work if you are anchoring more than one component that is already anchored.

Really pleased with LAMW and the immense work that goes into it.  :)
« Last Edit: August 23, 2017, 10:29:11 am by c4p »
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: LAMW: Adjust x/y
« Reply #3 on: August 24, 2017, 03:16:14 am »
Quote
Basically PosRelativeToAnchor/Anchor does not seem to work if you are anchoring more than one component that is already anchored.

No. You can!

Here my hints:

[please, update LAMW from github]

You can get some device information using "jForm" methods
and handling jForm  "OnJNIPrompt event":

 Self.GetScreenSize()  //"XLARGE" or "LARGE" or "NORMAL" or "SMALL"
 Self.GetScreenDensity()   //"XXHIGH" or "XHIGH"  or "HIGH" or "MEDIUM" or "LOW"

and property:
  Self.ScreenWH.Width
  Self.ScreenWH.Height

And then change the components  position and layout

[According to your need]

  jTextView1.PosRelativeToParent:= [rpTop, rpLeft];
  jTextView1.ResetAllRules();
  jTextView1.UpdateLayout();

  jButton1.LayoutParamWidth:= lpHalfOfParent;
  jButton1.PosRelativeToParent:= [rpCenterHorizontal];
  jButton1.PosRelativeToAnchor:= [raBelow];
  jButton1.ResetAllRules();
  jButton1.UpdateLayout();
« Last Edit: August 24, 2017, 05:49:45 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

c4p

  • Full Member
  • ***
  • Posts: 158
Re: LAMW: Adjust x/y
« Reply #4 on: August 25, 2017, 08:07:36 am »
Thank you!
I will try this tonight.
 :)
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

c4p

  • Full Member
  • ***
  • Posts: 158
Re: LAMW: Adjust x/y
« Reply #5 on: August 26, 2017, 12:08:43 am »
Hmm, still the same, cannot anchor and anchor.
ScreenDensity/Size functions work great though, very useful.
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: LAMW: Adjust x/y
« Reply #6 on: August 26, 2017, 12:55:10 am »

Hi c4p!

What layouting you need?
Can you post some picture?
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

c4p

  • Full Member
  • ***
  • Posts: 158
Re: LAMW: Adjust x/y
« Reply #7 on: August 26, 2017, 01:31:34 am »
Example:
I anchor editbox1 to Label1....editbox1 is to the right of label so I set PosRelativeToAnchor to rAlignBaseline and raToRightOf this works perfect!
If I then was to try and anchor another editbox or label to the right of editbox1, y coordinate resets to the top.
Maybe this is not possible?
I did a workaround by setting invisible label and setting it as an anchor and spacing out to a x position but this is not ideal as will not hold position with different screen density. Not major for me right now, but would be nice to get the anchor holding on more than one.
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: LAMW: Adjust x/y
« Reply #8 on: August 26, 2017, 04:12:37 am »

Please, if possible,  point in picture [attachment]  what layouting configuration parts you need...
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

c4p

  • Full Member
  • ***
  • Posts: 158
Re: LAMW: Adjust x/y
« Reply #9 on: August 26, 2017, 10:48:59 pm »
The graphic shows the component layout I need.
I need three components side by side, middle one is anchored to left one, then right one anchored to middle one. 
Right now I can only anchor middle to left but NOT right to middle.
I need it this way so when using high density or low density screens that the components are uniform and don't disappear off the screen or overlap.
:)
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

jmpessoa

  • Hero Member
  • *****
  • Posts: 2301
Re: LAMW: Adjust x/y
« Reply #10 on: August 27, 2017, 05:38:24 am »
Ok. 

Here is the picture [attachment]  and the ".lfm" code:

Code: Pascal  [Select][+][-]
  1. object AndroidModule1: TAndroidModule1
  2.   Text = 'AndroidModule1'
  3.   ActivityMode = actMain
  4.   object jTextView1: jTextView
  5.     PosRelativeToAnchor = []
  6.     PosRelativeToParent = [rpTop, rpLeft]
  7.     LayoutParamWidth = lpWrapContent
  8.     LayoutParamHeight = lpWrapContent
  9.     Text = 'jTextView1'
  10.   end
  11.   object jEditText1: jEditText
  12.     Anchor = jTextView1
  13.     PosRelativeToAnchor = [raBelow]
  14.     PosRelativeToParent = [rpLeft]
  15.     LayoutParamWidth = lpOneThirdOfParent
  16.     LayoutParamHeight = lpWrapContent
  17.     Text = 'jEditText1'
  18.   end
  19.   object jEditText2: jEditText
  20.     Anchor = jTextView1
  21.     PosRelativeToAnchor = [raBelow]
  22.     PosRelativeToParent = [rpCenterHorizontal]
  23.     LayoutParamWidth = lpOneThirdOfParent
  24.     LayoutParamHeight = lpWrapContent
  25.     Text = 'jEditText2'
  26.   end
  27.   object jEditText3: jEditText
  28.     Anchor = jTextView1
  29.     PosRelativeToAnchor = [raBelow]
  30.     PosRelativeToParent = [rpRight]
  31.     LayoutParamWidth = lpOneThirdOfParent
  32.     LayoutParamHeight = lpWrapContent
  33.     Text = 'jEditText3'
  34.   end
  35.   object jTextView2: jTextView
  36.     Anchor = jEditText2
  37.     PosRelativeToAnchor = [raAbove, raAlignLeft]
  38.     PosRelativeToParent = []
  39.     LayoutParamWidth = lpWrapContent
  40.     LayoutParamHeight = lpWrapContent
  41.     Text = 'jTextView2'
  42.   end
  43.   object jTextView3: jTextView
  44.     Anchor = jEditText3
  45.     PosRelativeToAnchor = [raAbove, raAlignLeft]
  46.     PosRelativeToParent = []
  47.     LayoutParamWidth = lpWrapContent
  48.     LayoutParamHeight = lpWrapContent
  49.     Text = 'jTextView3'
  50.   end
  51. end
  52.  

Note1:  All  jEditText are "anchored"  below  jTextView1
Note2: You can use the same model for two components... only
changing "LayoutParamWidth "  According to your need
« Last Edit: August 27, 2017, 05:44:09 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

c4p

  • Full Member
  • ***
  • Posts: 158
Re: LAMW: Adjust x/y
« Reply #11 on: August 27, 2017, 11:25:41 am »
Hmmm, starting to think there may be an issue with my form then, as I cannot anchor to another anchor.
Lazarus 2.0.12 r64642/FPC 3.2.0 LAMW v0.8.6.4 on Windows 10+Linux Mint 21.2, projects mainly built using AppCompat and Gradle v8.5

 

TinyPortal © 2005-2018