Android Question Mystic label shape

peacemaker

Expert
Licensed User
Longtime User
I have created the horizontal panel by the code

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private txtSearch As EditText  
    Private pnlTypes As Panel, hsv As HorizontalScrollView, lblTag() As Label
End Sub

Sub Show_Tags
    Dim cur As Cursor = Starter.SQL.ExecQuery("SELECT * FROM typeList")
    Dim cd As ColorDrawable
    Dim can As Canvas, bmp As Bitmap
    bmp.InitializeMutable(300dip, 50dip)
    can.Initialize2(bmp)
    cd.Initialize2(Colors.ARGB(255, 102, 102, 102), 17dip, 1dip, Colors.ARGB(255, 102, 102, 102))
    hsv.Panel.RemoveAllViews
    Dim prevLeft As Int = 12dip
    If cur.RowCount = 0 Then Return
    Dim lblTag(cur.RowCount) As Label
    For i = 0 To cur.RowCount - 1
        cur.Position = i
        Dim L As Label
        lblTag(i) = L
        lblTag(i).Initialize("lblTag")
        hsv.Panel.AddView(lblTag(i), 0, 15dip, 70dip, 35dip)
        lblTag(i).Background = cd
        lblTag(i).Text = cur.GetString("title")
        lblTag(i).TextColor = Colors.White
        lblTag(i).TextSize = 16
        Dim w As Int = can.MeasureStringWidth(lblTag(i).Text, Typeface.DEFAULT, lblTag(i).TextSize)
        lblTag(i).Width = w + 30dip
        lblTag(i).Gravity = Bit.Or(Gravity.CENTER_HORIZONTAL, Gravity.CENTER_VERTICAL)
        lblTag(i).Left = prevLeft
        prevLeft = lblTag(i).Left + lblTag(i).Width + 8dip
    Next
    hsv.Panel.Width = prevLeft
End Sub

It's the first screenshot.
If the searching EditText is not touched - no problem.
But if to tap this Edit text - the oval labels are ... got rectangle on the right, and label width is changed.
But this sub is not called anymore !

How to understand where ?
 

Attachments

  • 01.png
    01.png
    63.6 KB · Views: 286
  • 02.png
    02.png
    51.4 KB · Views: 269
Top