Git Product home page Git Product logo

Comments (5)

Carbs0126 avatar Carbs0126 commented on July 2, 2024

你找下view中的paint,有个专门“写字”的paint,改下这个paint的字体就可以了

from numberpickerview.

yecal avatar yecal commented on July 2, 2024

大神,我找到paint了,paint怎么改啊?
没找到paint.set方法

from numberpickerview.

Carbs0126 avatar Carbs0126 commented on July 2, 2024

在numberpickerview的init方法中,你找下mPaintText,然后看看能不能设置上字体

应该用下面的方法就可以
Typeface font = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD);
p.setTypeface( font );

字体最好是全局保存一个,否则可能有内存泄漏

from numberpickerview.

yecal avatar yecal commented on July 2, 2024

好了,设置完了,谢谢大神!
顺便总结一下:
1.将NumberPickerView提取出来放到自己的项目中。
2. 大概将这些代码放在init()中的大概323行。
Typeface typeFace =Typeface.createFromAsset(getContext().getAssets(),"PingFang Bold.ttf");
mPaintText.setFlags(Paint.ANTI_ALIAS_FLAG); //消除锯齿
mPaintText.setTypeface(typeFace);
设置如上代码,其中PingFang Bold.ttf为我自己放在assets目录文件夹下面的字体。
3.注意修改xml文件中的引用名称等。

from numberpickerview.

Carbs0126 avatar Carbs0126 commented on July 2, 2024

我不是大神,只是菜鸟一枚。
写的很详细,谢谢!
之前看过文章说,字体好像不要创建太多,占内存,全局保存一份就可以,我没注意过。

from numberpickerview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.