Android Question label size

Douglas Farias

Expert
Licensed User
Longtime User
how the best way to make a label auto ajustable?
i make a app on my tablet

example in my tablet i see

Douglas Farias - São Leopoldo


IN MY SMARTPHONE I SEE

Douglas Farias - Sã

how can i ajust only a labels for show 100% in a label not on custom view?
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
Use the android constant WRAP_CONTENT value which is -2.

FILL_PARENT value is -1.

You wont see the results in the designer if you use it, but when you run the app it will make the label just big enough to show the content. You can use it for width and height.
 
Last edited:
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
an example form a simple label with a long text?

i m want only width 100% *-* width is my problem =(
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
In the designer set the width to -2

If you are adding by code then it's:

B4X:
    Dim L As Label
    L.Initialize("")
    L.Color = Colors.Gray
    L.Text = "Test of background label sizing"
    L.TextColor = Colors.White
    Activity.AddView(L,10Dip,100Dip,-2,30Dip)
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
stevel05 it possible make this on design menu?

i make all my app using
SetLeftAndRight
SetTopAndBottom

for dont need add this what can i make in my code?
Activity.AddView(L,10Dip,100Dip,-2,30Dip)

nomecustom.SetLeftAndRight(45%x, 90%x)
nomecustom.SetTopAndBottom(22%y, 26%y)
 

Attachments

  • Sem título.jpg
    Sem título.jpg
    352 KB · Views: 174
Upvote 0

stevel05

Expert
Licensed User
Longtime User
In the designer scripts you would set the left position, then set the width to -2:

B4X:
Label1.Left = 45%x
Label1.Width = -2
 
Upvote 0
Top