Recent

Author Topic: LAMW. simple question but tricky. Anchoring  (Read 2567 times)

amartitegui

  • Jr. Member
  • **
  • Posts: 84
LAMW. simple question but tricky. Anchoring
« on: December 21, 2017, 08:41:31 pm »
Hi got a little question about sizes an anchoring.
Sometimes result is not what expected and donr really know why.
If i put a couple of jedit width to wrap content one with no anchors other to anchor first one. At rigth-of and baseline.
First with parent relative abxhor. Top and left.
Do same with another couple. But to anchor both couples i anchor first of second pair to first of first. Anchored left and below of.
Shows ok.
Then change first of second anchor to second of first.
Left anchored relevtive to parent and below-of second of first pair.
Shows on top of second.
Why?
Is there some place i can check hierarchy of anchoring relations?
Thanks

c4p

  • Full Member
  • ***
  • Posts: 157
Re: LAMW. simple question but tricky. Anchoring
« Reply #1 on: December 21, 2017, 11:09:12 pm »
Hi amartitegui,

I also encountered this problem and had a bit of a nightmare getting my anchoring right, setting below when they should have been above etc.
The way that worked for me was setting one main anchor and basing everything else off that anchor tended to work better. So BTN1 is the main anchor, then BTN2 below, set that to raBelow with BTN1 as the anchor, BTN3 to the right of BTN2 (raToRightOf/raAlignBaseline), with BTN2 as the anchor for BTN3. As you can see, base each anchor from BTN1, hope this makes sense. This could be an issue if you needed a button further away, but I would just use margins and +- away from the last anchor I needed. Not ideal but it works!
I found using more than one anchor independently resulted in the x and y going off the chart, so to speak.
You're not alone I have spent many hours on this :)
My LAMW app is here: https://play.google.com/store/apps/details?id=swbcdx.cap.shortwavelist
You should be able to see my anchoring on the screenshots there.
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: 2296
Re: LAMW. simple question but tricky. Anchoring
« Reply #2 on: December 21, 2017, 11:14:06 pm »

Hello amartitegui!

Please,  put here a draft/layout.. I will try some suggestion....
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

amartitegui

  • Jr. Member
  • **
  • Posts: 84
Re: LAMW. simple question but tricky. Anchoring
« Reply #3 on: December 22, 2017, 11:25:55 am »
See the image.
Ill talk about the white labels as textboxes(even if they are all jtextview)
I have a panel (with a header saying CONFIGURACION INTERIOR). wanna size heigh to wrap content ('cause some labels can become two liners).
modelo is anchored to configuracion interior (below of) and parent left.
I tried color label to be anchored to modelo-textbox below of and anchored to parent left.
same with herraje, and tapajuntas pairs (label+textbox).
WHY,
because when sizing textboxes, if they become two liners... dont want to overlap one over the next.
....
well im gonna try something.
thanks

 

TinyPortal © 2005-2018