Subject: Ellipsizing and Marquee text
In this post you find several routines to ellipsize and marquee texts in Labels.
What does ellipsize mean ? Look at the image.
MARQUEE means horizontal scrolling of the text.
START, MIDDLE and END work also with multiline Labels
MARQUEE works only in a single line Label
Sub: setEllipsize
Description: sets the ellipsizing of text
Code:
'Sets the Ellipsizing of a TextView (Label, EditText)
' Mode can be
' original text 'This is a test text'
'"START" ... This is a te
'"MIDDLE" This is ... text
'"END" This is a tes...
'"MARQUEE This is a test t
Sub setEllipsize(TextView As Label, Mode As String)
Dim jo = TextView As JavaObject
jo.RunMethod("setSingleLine", Array As Object(True))
jo.RunMethod("setEllipsize", Array As Object(Mode))
jo.RunMethod("setSelected", Array As Object(True)) ' needed for MARQUEE
End Sub
Sub: resetEllipsize
Description: removes ellipsizing
Code:
'Removes the Ellipsizing of a TextView (Label, EditText)
Sub resetEllipsize(TextView As Label)
Dim jo = TextView As JavaObject
jo.RunMethod("setSingleLine", Array As Object(False))
End Sub
Sub: setSingleLLine
Description: sets the Label to single line and allows scrolling of text
Code:
'Sets the TextView to single line
Sub setSingleLine(TextView As Label, SingleLine As Boolean)
Dim jo = TextView As JavaObject
jo.RunMethod("setSingleLine", Array As Object(SingleLine))
End Sub
Sub: setLines
Description: sets the line number of the Label
Code:
'Limits the line number to the given value
Sub setLines(TextView As Label, LineNumber As Int)
Dim jo = TextView As JavaObject
jo.RunMethod("setLines", Array As Object(LineNumber))
End Sub
Sub: setMarqueeRepeat
Description: sets the number of scrolling
Code:
'Sets the repeat limit
' default is three times
' set -1 for repeat indefinitely
Sub setMarqueeRepeatLimit(TextView As Label, Limit As Int)
Dim jo = TextView As JavaObject
jo.RunMethod("setMarqueeRepeatLimit", Array As Object(Limit))
End Sub
The JavaObject routines can also be used without a sub like this:
Code:
Private jobj As JavaObject
Private lblTest As Label
'
'
jobj = lblTest
jobj.RunMethod("setLines", Array As Object(2))
jobj.RunMethod("setEllipsize", Array As Object("END"))
Stop or run the horizontal scrolling can be done with:
Code:
jobj.RunMethod("setHorizontallyScrolling", Array As Object(False))
'or
jobj.RunMethod("setHorizontallyScrolling", Array As Object(True))
Dependencies: JavaObject library
Tags: Label, TextView, ellipsize, START, MIDDLE, END, MARQUEE, shadow
Attached a small test program.