B4A Library TickerView

A wrapper for this GitHub library https://github.com/robinhood/ticker



An Android text view with scrolling text change animation

ticker_main.gif



tickerview
Author:
SMM
Version: 0.01
  • TickerView
    Events:
    • click
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • EMPTY_CHAR As Char
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    Properties:
    • AnimationDuration As Int [write only]
    • Background As Drawable
    • CharacterList() As Char [write only]
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Parent As Object [read only]
    • Tag As Object
    • Text As String [write only]
    • TextColor As Int [write only]
    • TextSize As Int [write only]
    • Top As Int
    • Typeface As Typeface [write only]
    • Visible As Boolean
    • Width As Int


Example

Please note that EMPTY_CHAR field should be inserted at the first index of character list as shown in example , The app crashed before inserting it in the array .

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim time As Timer
    time.Initialize("time",1000)
    time.Enabled=True
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim tv As TickerView
End Sub
Sub time_Tick
    tv.Text=DateTime.Now

End Sub
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
'    Activity.LoadLayout("Layout1")
    tv.Initialize("")
    Activity.AddView(tv,0,0,50%x,50%y)

    tv.CharacterList=Array As Char(tv.EMPTY_CHAR,0,1,2,3,4,5,6,7,8,9)

End Sub

version 0.02 : TextSize is now float .
version 0.03 : Attempt to make text size close to other views text size .
version 0.04 : Added Gravity
version 0.05 : TextSize issue should be solved now . Thanks to NJDude and chuath
 

Attachments

  • tickerview.zip
    16 KB · Views: 225
  • tickerview102.zip
    16 KB · Views: 180
  • tickerview103.zip
    16 KB · Views: 183
  • tickerview004.zip
    16.1 KB · Views: 183
  • tickerview005.zip
    16.2 KB · Views: 223
Last edited:

chuath

Member
Licensed User
Longtime User
Nice work. However it still crash if "." is missing. So the CharacterList needs to be as below.
B4X:
tv.CharacterList=Array As Char(tv.EMPTY_CHAR,".",0,1,2,3,4,5,6,7,8,9)

TextSize doesn't seems to work though.
 
Last edited:

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Nice work. However it still crash if "." is missing. So the CharacterList needs to be as below.
B4X:
tv.CharacterList=Array As Char(tv.EMPTY_CHAR,".",0,1,2,3,4,5,6,7,8,9)

TextSize doesn't seems to work though.

I think you should add all characters that you will use later when updating text .

Did you try to set textsize to large number like 700? it worked for me
And in version 0.02 , I changed textsize to float .
 
Last edited:

chuath

Member
Licensed User
Longtime User
I think you should add all characters that you will use later when updating text .

Did you try to set textsize to large number like 700? it worked for me
And in version 1.02 , I changed textsize to float .

Yes, It works if i set it to a much higher number.
Now the task is to find out the relation of this "number" to a normal textsize like 12 or 14....;)

Edit: relation seems to be x3. Textsize of previous 20 seems to be 60 for this
 
Last edited:

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Yes, It works if i set it to a much higher number.
Now the task is to find out the relation of this "number" to a normal textsize like 12 or 14....;)

Edit: relation seems to be x3. Textsize of previous 20 seems to be 60 for this
You can try v0.03
 
Last edited:

NJDude

Expert
Licensed User
Longtime User
You have a problem scaling the text size, the text size should be in DIP, see the attached sample.

Not sure if possible but adding a GRAVITY property to the Text will make the lib a little better.

I used version 1.03 (but B4A IDE shows 0.03).
 

Attachments

  • TickerView_Sample.zip
    19.3 KB · Views: 141
Last edited:

somed3v3loper

Well-Known Member
Licensed User
Longtime User
You have a problem scaling the text size, the text size should be in DPI, see the attached sample.

Not sure if possible but adding a GRAVITY property to the Text will make the lib a little better.

I used version 1.03 (but B4A IDE shows 0.03).
There is a warning not to scale textsize because it gets scaled internally .
Your sample seems to work OK How did you want it to be ?

For Gravity I will check it and upload a new version .
And Yes there was a mistake :) versions are 0.0x
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Also, if you could add DIRECTION, the way it is now it only rolls down, look at the animation on your first post.
It seems that it decides direction depending on how far the next character is from the current one .
I added Gravity to version 0.04
 

chuath

Member
Licensed User
Longtime User
There are still problems with TextSize. My previous "estimation" of 3x for the value seems to be based on my 5.5" 1080p phone.
When using the same apk on 7" tablet. The size is different.
My guess is the conversion of TextSize must be according to the scale value of the given device based on dpi?
I am assuming that you just placed a x3 variable in the wrapper?

Maybe Erel have any tips on how to do it correctly?
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
There are still problems with TextSize. My previous "estimation" of 3x for the value seems to be based on my 5.5" 1080p phone.
When using the same apk on 7" tablet. The size is different.
My guess is the conversion of TextSize must be according to the scale value of the given device based on dpi?
I am assuming that you just placed a x3 variable in the wrapper?

Maybe Erel have any tips on how to do it correctly?
You are right . I am waiting for any hint or tip from experts :)
 

NJDude

Expert
Licensed User
Longtime User
You are right . I am waiting for any hint or tip from experts :)
I have already mentioned that to you on a previous post, if you look at the sample I wrote, adding "DIP" to the TextSize solves the problem, but, you get a warning from the IDE, you should handle that internally to keep it the same way B4A handles TextSize.
 
Last edited:

NJDude

Expert
Licensed User
Longtime User
There are still problems with TextSize. My previous "estimation" of 3x for the value seems to be based on my 5.5" 1080p phone.
When using the same apk on 7" tablet. The size is different.
My guess is the conversion of TextSize must be according to the scale value of the given device based on dpi?
I am assuming that you just placed a x3 variable in the wrapper?

Maybe Erel have any tips on how to do it correctly?

Just use DIP for TextSize, look at the sample I posted above, that will solve the problem, but like I mentioned on the post above, you will get a warning from the IDE, that can be ignored until it's corrected.
 
Last edited:

somed3v3loper

Well-Known Member
Licensed User
Longtime User
I have already mentioned that to you on a previous post, if you look at the sample I wrote, adding "DIP" to the TextSize solves the problem, but, you get a warning from the IDE, you should handle that internally to keep it the same way B4A handles TextSize.
Really sorry I got you wrong :D
I will update libs as soon as possible .
Thanks a lot .
 
Top