robinhood / ticker Goto Github PK
View Code? Open in Web Editor NEWAn Android text view with scrolling text change animation
Home Page: https://medium.com/robinhood-engineering/hello-ticker-20eaf6e51689
License: Apache License 2.0
An Android text view with scrolling text change animation
Home Page: https://medium.com/robinhood-engineering/hello-ticker-20eaf6e51689
License: Apache License 2.0
If a two digit ticker number is updated rapidly (maybe four times in a ten second period) an odd issue occurs in which the two digits begin to move toward one another and eventually overlap.
This issue is occurring for me when switching from the number 72 to the number 0. The two digit 72 remains and the numbers slowly collide.
Hi! When I use shadow, the characters are clipped in width (pre lollipop), how I fix this?
Thanks for library!
Can you add RTL language support ?
Please add a feature to Auto resize texts when texts exceeds tickerView bounds.
Like, I have to give fix width to tickerView and manage its text size according to its width. Then how can I manage it?
I have set the tickerview with simple text. Its not animating any numbers. Here is the code
<RelativeLayout >
<com.robinhood.ticker.TickerView
android:id="@+id/tickerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TickerView tickerView = (TickerView) findViewById(R.id.tickerView);
tickerView.setCharacterList(TickerUtils.getDefaultListForUSCurrency());
tickerView.setAnimationDuration(500);
tickerView.setText("$1000.34");
}
}
I dont see any animation of the text
You can see that the width of TickerView does a weird jump when you have the width set to wrap_content
and you go from a longer string, such as "August" to a shorter string, such as "July". It will appear normal at first, with the "July" text appearing centered within within the view. When you then set the text to a similarly short string, such as "June", you will see the text jump from being center aligned to being left aligned.
I am going to investigate this further and see if I can find a solution.
TextView
s are often baseline-aligned to other views. TickerView
should also support layout_alignBaseline
and other similar layout attributes.
Hey,
as the title says, I'd like to see the function isCharacterListSet() added to the TickerView, so that can be dynamically set once it's required(, instead of hoping I remembered to initialize it beforehand or get Thrown out ">_> ).
Coding-wise, given what I've seen, this would likely be a simple null check on the characterList field.
HI!
How can I achive the background material(green) like in your sample ticker View?
Hello,
Since the latest update from 1.2.0 to 1.2.1 or 1.2.2, I am receiving the following crash:
01-19 23:20:51.007 20955-20955/<package name> E/AndroidRuntime: FATAL EXCEPTION: main Process: <package name>, PID: 20955 java.lang.RuntimeException: Unable to start activity ComponentInfo{<package name>/<package name>.activities.<activity name>}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.robinhood.ticker.TickerView at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class com.robinhood.ticker.TickerView Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class com.robinhood.ticker.TickerView Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:334) at android.view.LayoutInflater.createView(LayoutInflater.java:647) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at <package name>.fragments.<fragment name>.onCreateView(<fragment name>.java:126) at android.support.v4.app.Fragment.performCreateView(Fragment.java:2354) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367) at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229) at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3221)
When reverting ticker to version 1.2.0, it works again.
I am using the latest Android API 27 in Android Studio with Gradle 4.
While testing ticker for simple incremental values using below code snippet,
float totalBill= 0;
public void onUpdate() {
final String currencyFloat = Float.toString((++totalBill) * 100);
tickerView.setText("$" + currencyFloat.substring(0, Math.min(digits, currencyFloat.length())));
}
I found that $ and . are also ticking along with changed digit. Ticker should avoid ticking nondigital characters.
Is it possible to change the view bounds of the ticker so it matches the parent? The problem is that i can see animation starts just a little above the the ticker, not from the top of the view. i have set ticker to match the parent and gravity to center, the ticker pop up in the center but the view doesn't match the parent, more like wrap content.
How to get current text from TickerView programmatically?
Would you please add support for the tools:text attribute like the TextView? It helps while designing the view.
gravity and typeface are in description to library
setters and xml attributes
but they aren't in the 1.0.0
can you please provide update for these features
I want to add border for each number ?
just like this view:
result image just like this:
https://github.com/bigbigpeng3/XCDemoSet/blob/master/borderText.png
I'm try to make different paint for it.but the result is not what I expected.
can add a shape or image background for each character ?
It can run on your demo, but put it in my project, I get error message.
wrap_content doesn't work when set value from a larger number to a smaller number.
lets assume || is a textview, change number from 1234567 to 123, the width of the textview turns out like below
|1234567|
|123 |
What I think it supposed to be is like below
|1234567|
|123|
Support for unsupported: single digits to 10, then 10 digits to another, and so on
Hello Team, Now scroll text happening top to bottom scrolling after change text, How do i change from Bottom to Top?
I'm currently using your library to display instantaneous values of flow from my sensor and what's happening is that the unit (L/m) is a suffix and it's ticking every time the value changes which, ideally, shouldn't happen. Any idea how I'd be dealing with a situation like this?
Just getting started with this library, I don't understand why it animates chars that are not part of the currently set character list. IMHO, these chars should not be animated at all.
For my use case, I'm displaying a percentage value (e.g. 81.03%
). However, the %
char is not included in the default lists provided by the TickerUtils
, thus the ticker animates it on every value change.
The straight forward fix for that was adding the %
char to a new character list and using it for the ticker:
protected void initializeLayout(View contentView) {
valueTickerView = contentView.findViewById(R.id.valueTickerView);
valueTickerView.setCharacterList(createTickerCharacterList());
}
private static char[] createTickerCharacterList() {
char[] newCharacters = new char[]{'%', '€'};
return extendCharacterList(TickerUtils.getDefaultNumberList(), newCharacters);
}
private static char[] extendCharacterList(char[] existingCharacters, char[] newCharacters) {
char[] extendedCharacters = new char[existingCharacters.length + newCharacters.length];
System.arraycopy(existingCharacters, 0, extendedCharacters, 0, existingCharacters.length);
System.arraycopy(newCharacters, 0, extendedCharacters, existingCharacters.length, newCharacters.length);
return extendedCharacters;
}
I think something like extendCharacterList
would be nice to have as part of the TickerUtils
. Note that the implementation above doesn't check for duplicate characters.
I've implemented this into my project, but it doesn't seem to work. Can you tell me what am I doing wrong? see code below...
final TickerView tickerView = (TickerView) findViewById(R.id.tickerView); tickerView.setCharacterList(TickerUtils.getDefaultNumberList()); String[] ticker_content = {"Lorem ipsum dolor sit amet", "Lorem ipsum dolor sit amet", "Lorem ipsum dolor sit amet"}; int idx = new Random().nextInt(ticker_content.length); tickerView.setText(ticker_content[idx]);
PS: I've added the .xml view and gradle lib
Thanks for this library, I think I will be able to do great things with it. Sadly I am greedy and would like another feature:
It would be nice if the numbers did not count up when going from 0->9 when the overall number is getting smaller. Not sure if there is a way to do this.
My character list is:
static char[] characters = new char[]{TickerUtils.EMPTY_CHAR, ':', '9', '8', '7', '6', '5', '4', '3', '2', '1', '0'};
As you can see when the ticker goes from 07:53:20 to 07:53:19, the ticker does a huge animation when all I want it to do is go from 9 to 0 and 2 to 1, however I can only specify one character list.
I was using Ticker and noticed that I'm not getting autocomplete in Android Studio 3.0.1 on styleable attributes. I dug in a little bit and discovered that because <declare-styleable name="ticker_TickerView">
isn't named the same as its custom view class Studio can't autocomplete. There's a standard lint shipped for this:
#73 introduces a backwards incompatible change in preparation for a major release. Would you be open to a PR that renames the XML tag for v2.0.0? This change should be compile time safe and prompt folks to update their XML/source.
Would it be possible to add in functionality to extend the capabilities for date/time values? Maybe add logic for timers or countdowns?
Hello,
I'd like to have textStyle support too so I can make my text bold. I am using the textAppearance tag but it does not support textStyle="bold" yet.
Thanks!
when transform 15233 to 9151 or reverse,in the LevenshteinUtils,method computeColumnActions has mistake,turn the number to 152335 & 915
Thanks for this lib!!!
Its possible add support for text with different length?
For example, the first word was 8 characters in length, and the second would be 20 characters in length
And when I set the second word, it is drawn outside the 'TickerView'
It is possible to add a function to automatically equalize the text size or transfer a part of the text to the second line?
<ScrollView
android:id="@+id/svWord"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<com.robinhood.ticker.TickerView
android:id="@+id/tvWord"
android:background="@color/colorPrimary"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="36sp" />
</ScrollView>
OnePlus One A0001
Android 6.0.1
Cyanogen OS 13.1.2
There's a bug that impacts the smoothness of the animations/transitions. It happens when the ticker needs to resize the dollar value string, for example, when it transitions from above $100 to below $100, or from above $10 to below $10. I've recorded a video of my screen to demonstrate the issue on my device:
https://www.dropbox.com/s/y4k3f3u6jb3wulm/device-2017-09-21-104722.mp4
This has been happening for well over a year, maybe longer. When will this be resolved?
It seems there's no way to add shadow on numbers because
TickerView
extends View
instead of TextView
.
I tried with TickerTextAppearance
, but it didn't work.
What would be the best way to implement the text shadow?
It would be useful to be able to make use of the databinding library to update the ticker, to follow MVVM design principles. Is there any way to do this currently?
e.g:
<com.robinhood.ticker.TickerView
android:id="@+id/opponent_score_ticker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/text_large"
android:text="@{viewModel.number}"/>
Hi,
I've got a TickerView
sitting inside a CoordinatorLayout
. I'm making the text size smaller as the screen is scrolled up, using a CoordinatorLayout.Behavior
and RecyclerView.OnScrollListener()
. While the text size shrinks correctly, the character spacing doesn't seem to update. To illustrate:
becomes
Approaches that I've tried so far without success:
Increasing right padding: If I set the right padding with the view width set to wrap_content
, the view size increases. If I set it to a fixed width, the right edge of the view gets cropped.
setAnimateMeasurementChange(true)
: Seems to have no effect.
balance.setText(text)
: Retrieving and setting the same text on the view in hopes of triggering a remeasuring of the character widths.
Calling balance.requestLayout()
manually on every update, and a variety of permutations of using this combined with the other approaches above.
Is there another approach that you could suggest? Thanks!
How can I use the euro-symbol instead of a dollar sign?
Hi, I'm trying to use your library to swap letters which means that I need to use the Greek latin alphabet letters with accents, etc.
Right now I just passing as the alphabet the 255 chars from the ascii table, but this is not the best solution because there are chars that have no printable representation and "blurry" also the animation when passing from one char to another...
Do you have a better solution?
Thanks.
What I'm doing right now:
alphabetlist = new char[255];
alphabetlist[0] = TickerUtils.EMPTY_CHAR;
for (int i = 0; i < 255; i++) {
alphabetlist[i] = (char) (i);
}
getText() fucntion is not available in TickerView
Hello,
I would love a feature where it possible to dynamically change the textSize to fit into the view? Can't use my resizable textview anymore with this library.
There is a setText() method, but the getText() is missing.
would u pls add a method to add animation listener?
Repro:
Hey folks, I'm trying to understand how does TickerUtils.getDefaultListForUSCurrency()
work, but I'm unable to wrap my head around it. To be more specific, how does it ignore the dollar character? The only thing I've been able to figure out so far is that it probably has something to do with line numbers 38 and 39.
I'd like to use the rupee symbol (₹, \u20b9)
. Can you please help me out here?
When calling ticker.setText("value") for the very first time, Ticker tries to not animate this call by checking if getWidth == 0. I think this check is currently broken.
I'm proposing two things:
!getText().isEmpty()
for the animate
argument to the 2 argument constructor.The gif has three Scrolling effect
up\down\random up and down
but i am not found up or down effect
please guide me how to scroll up OR scroll down
Thank you very much
Great animation too bad you can't change the font
Hello, can this do the same effect as the gas meter?
I have seen that you have closed #16 .
But I think we should add an animation listener to that. In my case I'm showing ticker in red/green colour depending on whether the change is positive/negative. But after the animation I want to make it black again.
This may be the case with some of the people who wants to use TickerView.
Thank you for this awesome library. :)
support attribute android:textAppearance.
The current animation for changing size (e.g. "1234" to "12345") is a bit funky when the animation is slowed down. Investigate how to improve this behavior.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.