Hello, several EditText and a Label that have the same height, font, size, etc. are displayed well in a Label and are displayed badly (cropped) in the EditText.
Both have a background to put rounded corners with this code.
How can I fix this?
Thanks.
B4X:
Sub Redondear ( iClrFondo As Int ) As ColorDrawable
Dim cd As ColorDrawable
Dim clrFondo As Int
'
If iClrFondo=0 Then
clrFondo = globales.iColorCelesteMedio
Else
clrFondo = iClrFondo
End If
Dim const clrBorde As Int = globales.iColorCelesteOscuro
'
cd.Initialize2(clrFondo,16dip,1dip,clrBorde)
'
Return cd
End Sub
When you are working with colorDrawable, you have to create a colorDrawable for each view. You cannot reuse the same. The recommended way is to use B4XView and SetColorAndBorder
for instance:
B4X:
Dim l as b4xView
l.SetColorAndBorder(xui.Color_Red, 7dip, xui.Color_Magenta, 10dip)
Hi, the color and border works fine, as with the previous method, but the text problem remains the same. It does not take advantage of the space there is, so I have to put a very small letter so that it is not cut.
However, the Label shows perfectly all the text.
I have used this code:
B4X:
PaintBackground2(False,edUnidades1)
PaintBackground2(False,edUnidades2)
PaintBackground2(False,edUnidades3)
Sub PaintBackground2( bFocused As Boolean, ed As EditText )
Dim const clrFondoConFoco As Int = globales.iColorCelesteClaro
Dim const clrFondoSinFoco As Int = globales.iColorCelesteMedio
Dim const clrBorde As Int = globales.iColorCelesteOscuro
Dim clrFondo As Int
'
If bFocused Then
clrFondo = clrFondoConFoco
Else
clrFondo = clrFondoSinFoco
End If
'
Dim l As B4XView = ed
l.SetColorAndBorder(clrFondo,1dip,clrBorde,16dip)
'
End Sub
I just want to point out that the problem is not the color or the border, but the problem is the text that is cut off.
I have made several tests and apparently the problem occurs when the screen is smaller than 6" because on a 7" or larger tablet it looks fine, the text is not cut.
The above screenshots are of 5" and 6" smartphones.
I was in front of a similar problem when the user sets an special value for the scale of the font, in the accesibility menu on their smartphones. When I set a specific font size for my views, if the user got a higher value on their font scale, the font looks cropped.
Thanks friend, the only solution I have found is to increase the height of the EditText when the screen is less than 6".
I have tried the link you have indicated and it tells me that the font size is the same as the one I am trying.
What I find strange about all this is that apparently the EditText doesn't take advantage of the space, it has a lot of wasted space at the top and bottom, and only leaves a narrow space for the text.
I don't know why, but I suppose that it should have the same behavior as the labels, which do use all the space.
Thanks.
Look at them with a bit of code. The Designer doesn't seem to show the default values but the default values are different. EditText for some reason has ridiculously large Padding values (IMHO) but Label Padding values are all 0 (I think).
You have been getting a lot of suggestions on this. How about another one:
Sometimes it is much better if you comment or remove AutoScaleAll from the designer script. In some cases, it can skew views
If globales.iSizeScreenPulgadas<6 Then
Dim aVistas() As View
aVistas = Array As View(edCodArt,lbedDescripcionArt,lbedStockTotal,edUnidades1,edUnidades2,edUnidades3,edPrecio,edRegalo,edDcto1,edDcto2,edDcto3,edTotal)
For Each v As View In aVistas
If v Is EditText Then
Dim v2 As EditText = v
v2.Padding = Array As Int (0,0,0,0)
End If
Next
End If