-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use a different Typeface? #17
Comments
sorry i have not add customizing font function, you can custom font in NumberPickerView by using code:
when i will add this function later |
Thanks, for fast answer. |
After some search, I manage to import the project as module and was able to edit the file but what I should put in
|
sorry for not replying in time, you can add a method
and invoke this method outside in oncreate method , if you want to change typeface dynamicly, using mNumberPickerView.invalidate( ) after using this method |
No Problem :) |
if you have used MyFont.ttf, you can use a static value to refer to this MyFont.ttf, in this way you can avoid memory leak, because every time you use
MyFont.ttf will be created again and added into memory. |
I don't understand what you mean by "...use a static value to refer to this MyFont.ttf". |
i mean you can use cache to refer to MyFont.ttf, in this way, if you use MyFont.ttf again, you can get MyFont.ttf from cache,
this will avoid memory leak |
Ah okay, I got it now. I'll change it. |
if there are many numberpickerviews in you app( or other views which use MyFont.ttf), there will be many copy of MyFont.ttf, but in fact only one MyFont.ttf is enough |
Cool, I got it :) Thank you very much. Off Topic: Like in this gif: |
i have not add this function, if you need this function now, you can add some code into
and get the index of current selected item by |
i have added a method picker.setOnValueChangeListenerInScrolling(...); you can get changed value while in scrolling and i have also added two methods for changing typeface of text/hint in NumberPickerView, |
Oh, Great, `
` Is there a better way to make it as smooth as in the gif |
this callback will be invoked once as number value changed for 'one item', and this callback runs in main thread , if you want to do some complicated work in this callback such as play sound, it may make scrolling lag. To make scrolling smoothly you can use handler to send message in this callback ,or make callback tasks run in a new thread, if it still lag, you can send your code to me ,and maybe i can refine this project according to your code |
Hi, I sent just you the project via email, I planned to add a scrolling sound but It's not much of a big deal if it may create (lag) problems... If you need any info, let me know. |
And by the way, I've try the project in that gif on my phone and it was working smoothly, just like in the gif. I found that project from here, Just in case it may help. |
@Carbs0126 Can you update the version in the README file to 1.1.1? I was trying to branch the repo to add the Typeface functionality, but saw that it was already implemented in this version (which is not refereed to anywhere). |
I have created a fork of the project which allows custom font loading from xml itself. I will be glad if you can take a look at it. |
I to change the default typeface/font for NumberPickerView?
I want use a custom font.
The text was updated successfully, but these errors were encountered: