Android Question Strange layout behavior

Slacker

Active Member
Licensed User
Longtime User
Hello Folks, i suppose there's something i didn't understand well, but here is what's happen. I know it's hard to understand in this way, but i will try to explain the concept as well.

I have set a custom variant of 320 x 800 with a panel inside (i have a long panel) positioning JUST labels views with text, by dinamically by code; i used just DIP measure, for example Label12.Top = Label1.Top + 10dip and calculated height with "MeasureMultilineTextHeight" method.

What's happen is that on a 320 x 480 all views are located corretly in the panel; when i move on my tablet of 1024 x 600 resolution, i see a bit messed positions... there's no keeping of the correct distance, some labels have a bit wrong height respect to 320 x 480, although the routine code is the same. In both device the scale is 1 (the scale variant i used is 1 too).

Any suggestions please ? I think i have to undestand something better.

Thank you !
 

Slacker

Active Member
Licensed User
Longtime User
Yes Klaus, i know. I try in this way now. See this code:

B4X:
L = p.GetView(FindViewIndex(p, "HimK"))
    L.Text = Utils.GetAppString("ProfileHimLb")
 
    L.top = top1
   
    measure = StrUtils.MeasureMultilineTextHeight(L, L.Text)
 
    top1 = top1 + measure + 9dip
   
    L = p.GetView(FindViewIndex(p, "HimAgeK"))
    L.Text = Utils.GetAppString("ProfileAgeLb")
 
    L1 = p.GetView(FindViewIndex(p, "HimAgeV"))
    L1.Text = pGeneralInfo.ageMale
   
 
    L.top = top1
    L1.top = top1
 
    measure = StrUtils.MeasureMultilineTextHeight(L1, L1.Text)
 
    top1 = top1 + measure + 8dip
   
    L = p.GetView(FindViewIndex(p, "HimProfessionK"))
    L.Text = Utils.GetAppString("ProfileProfessionLb")
 
    L1 = p.GetView(FindViewIndex(p, "HimProfessionV"))
    L1.Text = pGeneralInfo.professionM
   
 
    L.top = top1
    L1.top = top1
 
    measure = StrUtils.MeasureMultilineTextHeight(L1, L1.Text)
 
    top1 = top1 + measure + 8dip
   
    L = p.GetView(FindViewIndex(p, "HimSexAttitudeK"))
    L.Text = Utils.GetAppString("ProfileSexAttitudeLb")
 
    L1 = p.GetView(FindViewIndex(p, "HimSexAttitudeV"))
    L1.Text = pGeneralInfo.sexOrientationM
 
 
    L.top = top1
    L1.top = top1
 
    measure = StrUtils.MeasureMultilineTextHeight(L1, L1.Text)
 
    top1 = top1 + measure + 8dip
   
    L = p.GetView(FindViewIndex(p, "HimDepilationK"))
    L.Text = Utils.GetAppString("ProfileDepilationLb")
 
    L1 = p.GetView(FindViewIndex(p, "HimDepilationV"))
    L1.Text = pGeneralInfo.depilationM
   
 
    L.top = top1
    L1.top = top1
 
    measure = StrUtils.MeasureMultilineTextHeight(L1, L1.Text)
 
    top1 = top1 + measure + 8dip
 
    L = p.GetView(FindViewIndex(p, "HimSexKissK"))
    L.Text = Utils.GetAppString("ProfileSexKissLb")
 
    L1 = p.GetView(FindViewIndex(p, "HimSexKissV"))
    L1.Text = pGeneralInfo.kissM
   
 
    L.top = top1
    L1.top = top1
 
    measure = StrUtils.MeasureMultilineTextHeight(L1, L1.Text)
 
    top1 = top1 + measure + 28dip
   
    'continue to position other labels....

As you see i place several labels calculting TOP; at the end of the code above, after i measure the last label's text, i set 28dip to create more vertical space. In the tablet of 1024 x 600 resolution (using identical variant of the layout), i see a light displacements around and some labels are just separator lines created inserting text like this underscore sequences --> "____________________________________________________"; these labels are a little displaced respect the correct result i get *with the same code* in my smart phone of 320 x 480 resolution, where everything is shown as i expected. Further, measuring with MeasureMultilineTextHeight() some labels's text, i get different distance spaces comparing the the result in between the 2 devices with the different resolution.

I wonder if this behavior is expected because the result i get in Tablet is inacceptable....
 
Upvote 0

Slacker

Active Member
Licensed User
Longtime User
I know it's hard, but i have to do a lot of stuff to give you a fully functional piece of project. There are not any further stuff over what i wrote above. The labels's height is set by designer in the layout and it's default ones. There are not percentage set in any part of code, neither variant (i have just one custom variant of 320 x 800 as i need a long vertical space.

I will to recheck accurately but i have done this thousand of time... and i have no found nothing of suspected.... :O

I Always create 2 variants, portrait and landscape; i test them on my smart phone... if it's ok, i should have correct results even to tablets with different resolutons, but i have received unexpected results..
 
Upvote 0

Slacker

Active Member
Licensed User
Longtime User
Yes, i Always use autoScaleAll in my variants.
 
Upvote 0

Slacker

Active Member
Licensed User
Longtime User
I will update you asap Klaus, thank you the same for the moment.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…