Android Question Marquee in labels doesn't work


Licensed User
Longtime User
I created this class, but Marquee in the labels doesn't work. It works when slide the status bar, but I don't know why, I guess 'cause the panel lost the focus:

' Custom MsgBox Labels v1.0
' By J.R. Sonora / Avansys - Based on the class CustomMsgBox by NJDude v1.4

Sub Class_Globals

    Private oPanelTrasero As Panel
    Dim oTop As Int : oTop = 10dip
    Private oIcono As ImageView
    Dim oPanel As Panel
    Private oSombra As Panel
    Dim oTitulo As Label
    Private oScroll As ScrollView
    Dim oSiPanel As Panel
    Dim oNoPanel As Panel
    Dim oCancelarPanel As Panel
    Dim oSiTitulo As Label
    Dim oNoTitulo As Label
    Dim oCancelarTitulo As Label
    Dim oActivity As Activity
    Dim delta As Int
    Dim rate As Float
    Dim scale As Float

End Sub

'Initializes the Custom MsgBox.
Public Sub Initialize(Activity As Activity, MsgBoxName As String, Width As Double, Height As Double, icon As Bitmap)
    ' Se copian los valores
        oActivity = Activity
    ' Se inicializan los objetos
        oScroll.Initialize2(60dip, "")
    ' Se obtienen los datos de pantalla
        delta = ((100%x + 100%y) / (320dip + 480dip) - 1)
        rate = 0.3
        scale = rate * delta + 1
    ' Se coloca el panel trasero
        Activity.AddView(oPanelTrasero, 0dip, 0dip, 100%x, 100%y)
        oPanelTrasero.Color = Colors.ARGB(160, 0, 0, 0)
    ' Al panel trasero se le agrega el panel MsgBox
        oPanelTrasero.AddView(oPanel, 0dip, 0dip, 100%x, 100%y)
        oPanel.Width = Width
        oPanel.Height = Height
        oPanel.Color = Colors.DarkGray
        oPanel.Left = (100%x - oPanel.Width) / 2
        oPanel.Top = (100%y - oPanel.Height) / 2       
    ' Se agrega la sombra al panel
        oPanelTrasero.AddView(oSombra, oPanel.Left + 5dip, oPanel.Top + 5dip, oPanel.Width, oPanel.Height)
    ' Se crea el cuerpo del MsgBox
        oPanel.AddView(oIcono, 5dip, 5dip, 50dip, 50dip)
        oPanel.AddView(oTitulo, 0dip, 0dip, oPanel.Width, 60dip)
        oPanel.AddView(oScroll, 5dip, 70dip, oPanel.Width - 10dip, oPanel.Height - 124dip)
        oPanel.AddView(oSiPanel, 0dip, oPanel.Height - 50dip, (oPanel.Width * 0.65) - 2, 50dip)
        oPanel.AddView(oCancelarPanel, (oPanel.Width * 0.65) + 2, oPanel.Height - 50dip,  (oPanel.Width * 0.35) - 2, 50dip)           

        oTitulo.Text = MsgBoxName.Trim
          oTitulo.Width = oPanel.Width - oTitulo.Left - 10dip
        oTitulo.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.CENTER_HORIZONTAL)
        oTitulo.TextColor = Colors.Cyan
        oTitulo.TextSize = oTitulo.TextSize * scale + 7
        SetEllipsize(oTitulo, "MARQUEE")
        oSiPanel.Color = Colors.DarkGray
        oSiPanel.AddView(oSiTitulo, 0dip, 0dip, oSiPanel.Width, 30dip)
        oSiTitulo.Gravity = Gravity.CENTER_HORIZONTAL
        oSiTitulo.Top = ((oSiPanel.Height - oSiTitulo.Height) / 2) + 5dip
        oSiTitulo.TextColor = Colors.White
        oSiTitulo.Text = "Compartir"

        oCancelarPanel.Color = Colors.DarkGray
        oCancelarPanel.AddView(oCancelarTitulo, 0dip, 0dip, oCancelarPanel.Width, 30dip)
        oCancelarTitulo.Gravity = Gravity.CENTER_HORIZONTAL
        oCancelarTitulo.Top = ((oCancelarPanel.Height - oCancelarTitulo.Height) / 2) + 5dip
        oCancelarTitulo.TextColor = Colors.White
        oCancelarTitulo.Text = "Ok"
    Separadores(Colors.Cyan, Colors.Gray)

End Sub

Public Sub ShowMessage(Title As String, Message As String)
    Dim mensaje As Label : mensaje.Initialize("")
    mensaje.TextSize = mensaje.TextSize * scale + 1   
    mensaje.Text = Message
    mensaje.Gravity = Gravity.CENTER_VERTICAL
    SetEllipsize(mensaje, "MARQUEE")
    Dim titulo As Label : titulo.Initialize("")
    titulo.TextSize = titulo.TextSize * scale + 1   
    titulo.Text = Title & ":"
    titulo.Gravity = Gravity.CENTER_VERTICAL
    SetEllipsize(titulo, "MARQUEE")
    oScroll.Panel.AddView(titulo, 5dip, oTop, oScroll.Width * 0.50, oPanel.Height * 0.06)
    oScroll.Panel.AddView(mensaje, oScroll.Width * 0.50 + 5dip, oTop, oScroll.Width - 5dip, oPanel.Height * 0.06)
    oTop = oTop + (oPanel.Height * 0.05) + 10dip
    oScroll.Panel.Height = oTop

End Sub

'Display line under the Custom MsgBox and button separators
Public Sub Separadores(TitleSeparator As Int, ButtonSeparator As Int)

    Dim LineSeparator As Canvas                   
    LineSeparator.DrawLine(0dip, 65dip, 100%x, 65dip, TitleSeparator, 3)
    LineSeparator.DrawLine(0dip, oSiPanel.Top - 2dip, 100%x, oSiPanel.Top - 2dip, ButtonSeparator, 1)
    LineSeparator.DrawLine(oPanel.Width * 0.65 , oSiPanel.Top - 2dip, oPanel.Width * 0.65, oPanel.Height, ButtonSeparator, 1)
End Sub

'Display a drop shadow
Public Sub ShowShadow(Color As Int)
    oSombra.Color = Color                   
End Sub

Private Sub PressedButton_Touch(Action As Int, X As Float, Y As Float)

    Dim Pressed As Panel : Pressed = Sender
    If Action = 0 Then Pressed.Color = Colors.ARGB(255, 0, 140, 140)
    If Action = 1 Then
        Pressed.Color = Colors.DarkGray
        oPanelTrasero.Visible = False
        'If SubExists(oModulo, oEvento & "_Click") Then CallSubDelayed(oModulo, oEvento & "_Click")
    End If

End Sub

Private Sub BackPanel_Touch(Action As Int, X As Float, Y As Float)
End Sub

Sub SetEllipsize(TextView As Label, Mode As String)
    Dim r As Reflector
    r.Target = TextView
    r.RunMethod2("setSingleLine", True, "java.lang.boolean")
    r.RunMethod2("setEllipsize", Mode, "android.text.TextUtils$TruncateAt")
    r.RunMethod2("setSelected", True, "java.lang.boolean")
End Sub

I call this class in the follow code:

Sub ListaWiFi_ItemClick(Index As Int, Value As Object)
    wifi = Operaciones.listWifiUnique.Get(Index)
    Dim msg As cMsgBox
    msg.Initialize(Activity, wifi.Get("SSID"), Activity.Width * 0.90, Activity.Height * 0.90, Null)
    For i = 0 To wifi.Size-1
        Dim key As String : key = wifi.GetKeyAt(i)
        If key.EqualsIgnoreCase("key_pass") = False AND key.EqualsIgnoreCase("finpass") = False AND key.EqualsIgnoreCase("key_encr") = False AND key.EqualsIgnoreCase("key_thumb") = False Then msg.ShowMessage(wifi.GetKeyAt(i), wifi.GetValueAt(i))
End Sub

Why is that?


Licensed User
Longtime User
marquee in the normal Android TextView only works if the view has the focus. This is a limitation of the standard TextView and can only be changed if you create a library with an extended version of the TextView object.

Solution how to extend the normal TextView is explained here.
Upvote 0


Licensed User
Longtime User
This is a little project where I'm using marquees, you should click in item and a dialog appear, but marquee doesn't work, you should slide down the status bar and then marquee works.




    351.8 KB · Views: 304
Upvote 0


Licensed User
Longtime User
I solve this making the menu of the application appears and disappears.

I know it's a bad solution, but it worked.
Upvote 0