Android Question Views position and alignment from code

Sub7

Active Member
Licensed User
Longtime User
Hello, i'm having some problems while trying to align and dock views added from code.

For example if i were using the designer i would dock two labels in this way from the designer script:
label2.top = label1.bottom, that's ok.

But what when i've added all views from code? How i can dock the various views so that i will get the same result in all different screens?

I've tried messing with %x and %y but i don't think is the correct way, infact the app will look different from screen to screen.

For example here i am using an action bar and i want to dock my ads exactly under the action bar, the code is not complete but understandable.

Code: Copy
 ActionBar.Initialize(Activity, Me, "Manager", Null, Colors.ARGB(255, 83, 90, 175), Colors.ARGB(255, 47, 35, 86), True, True, False)

Activity.AddView(adbox, 0dip, 27%y - height, 100%x, height)

Thank you
 
Last edited:
I've marked the question as solved too early: I cannot get the height of NJDude compact actionbar.

Code: Copy
  Dim r As Reflector
    r = ActionBar
    r.Target = ActionBar
    Dim h As Int
    h = s.RunMethod("getHeight")
    Log(h)
 
Upvote 0
Back
Top