Android Question Avoid this "effect" ( dip Vs % )

MarcoRome

Expert
Licensed User
Longtime User
Hi all.
Often when i use different device. In different app i have this "effect" ( the text that you see is Hint Text )

upload_2017-2-5_10-23-49.png


in another device:

upload_2017-2-5_10-24-5.png



The code in design is:
B4X:
edt_descrizione.SetLeftAndRight(3%x, 97%x)
edt_descrizione.SetTopAndBottom(Label4.Bottom, 40dip)
edt_descrizione.Height = 50dip

i'm sure that this "problem" is dip ( in my example 40dip ).
But if i wanted to replace the dip with the percentages what is the way. Explaining better 40dip what is equivalent to % ??
Thank you
Marco
 

sorex

Expert
Licensed User
Longtime User
I usually use 95%x for something like that which give 2.5%x padding on the left and right after centering it to the full width.

for the height you could go for %x or %y. in some cases it's better to use %x for the height/positioning aswell otherwise gaps or sizes might look too overstretched
on these long looking 16:9 screens.

I guess it's all situation depending.
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
I usually use 95%x for something like that which give 2.5%x padding on the left and right after centering it to the full width.

for the height you could go for %x or %y. in some cases it's better to use %x for the height/positioning aswell otherwise gaps or sizes might look too overstretched
on these long looking 16:9 screens.

I guess it's all situation depending.
Thank for your answer @sorex, if you see in code i have 3% till 97%. The question is :
"if i wanted to replace the dip with the percentages what is the way. Explaining better 40dip what is equivalent to % ??"
Because i can write also:
B4X:
edt_descrizione.SetLeftAndRight(3%x, 97%x)
edt_descrizione.SetTopAndBottom(Label4.Bottom, 40dip)
edt_descrizione.Height = 3%y
But the 3%y is equivalent to dip ??
And again why the "Hint text i see" in this mode ( also if i use in designer AutoscaleAll ) ?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Do you use AutoScaleAll?
If yes the problem is probably that the TextSize is increased but the Height remains at its value therefore the text could become too big.
How do you set the other views in the Designer Script?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
But the 3%y is equivalent to dip ??
There is no equivalent.
40dip is about 1/4 of an inch on any device (160dip is about 1 inch).
10%y is 10% of the screen height. It will be almost the double on a 10'' screen than on a 5'' screen.
 
Last edited:
Upvote 0

sorex

Expert
Licensed User
Longtime User
you also need to decide what your app wants to do.

1. show the same amount of data (with possible empty gap at the bottom)
2. show more data if the screen gets larger.

you also might need to add scaling to you fonts to make it look identical for case 1.
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
There is no equivalent.
40dip is about 1/4 of an inch on any device (160dip is about 1 inch).
10%y is 10% of the screen height. It will be almost the double on 10'' than on a 5'' screen.
Thank you for your answer @klaus.
It is clear what you said.
I was just wondering if there is a way to have the proportionate fields.
For example in the designers we type 40, to have a proportionate work (1/4 inch) in order to always have the same filling height (a difference in the percentage that would change the height according to the type of device).
So in the example above, while having the same height on two different devices but "Hint Text" is displayed in a different way, despite having set AutoscaleAll.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
The problem is what I explained in post #4.
You use AutoScale which will adjust the Left, Top, Width, Height and also the TextSize.
The scale factor depends on the layout variant and the AutoScaleRate which os 0.3 by default.
If, after that, you set a 'none scaled' value like 40dip, the TextSize could be too big.
Is AutoScale not enough, you could play with the AutoScaleRate.
What layout variant are you using?
Downscaling, with AutoScale, a big layout to a small one can lead to bad results.
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
The problem is what I explained in post #4.
You use AutoScale which will adjust the Left, Top, Width, Height and also the TextSize.
The scale factor depends on the layout variant and the AutoScaleRate which os 0.3 by default.
If, after that, you set a 'none scaled' value like 40dip, the TextSize could be too big.
Is AutoScale not enough, you could play with the AutoScaleRate.
What layout variant are you using?
Downscaling, with AutoScale, a big layout to a small one can lead to bad results.
Thank you Klaus for your time.
The layout is only for device 5" - 7" ( Script - General ). i will try to use Autoscale
 
Upvote 0
Top