Android Question Why are EditText and Labels displayed differently?

vecino

Well-Known Member
Licensed User
Longtime User
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
 

vecino

Well-Known Member
Licensed User
Longtime User
Hi, and how can I work with that B4XView as if it were an EditText? to give it focus, assign it an "InputType", etc.
Thanks.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
It takes 100-hour days to keep up with everything new
Thanks, friends.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Note that it wasn't released yet. For now:
B4X:
Dim l as b4xView = EditText1
l.SetColorAndBorder(xui.Color_Red, 7dip, xui.Color_Magenta, 10dip)
I had not seen this message, thank you.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
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

 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
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.

 
Upvote 0

Carlos Huerta

Member
Licensed User
Longtime User
Hi there !.

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.

Please take a look of this thread -> https://www.b4x.com/android/forum/threads/b4x-font-size-independent-of-os-settings.112570/ . This solution revolves on the use of the specific value of the user's font scale, and defines new font sizes for your views.

I hope you find the solution of your problem. Hang in there, you can do it!
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
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.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
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).
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
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
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
agraham said:
... padding ...
I think you are right, I used this code:

B4X:
    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

And the result is this:



Thank you!!!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…