Custom font rendering on Android 4.0 (Ice cream sandwich)

后端 未结 4 2269
囚心锁ツ
囚心锁ツ 2021-02-13 03:08

While testing an application that uses Helvetica Neue as its primary font on Android 4.0 I have found that there is an inconsistency in typeface rendering compared to multiple d

4条回答
  •  离开以前
    2021-02-13 03:51

    ICS v14+ uses the Roboto font found here:Android design

    It would be better to set the type face manually if you want it to display the same across all versions.

    Typeface mBoldType = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Bold.ttf");
    TextView mTextView = findById(R.id.text1);
    mTextView.setTypeface(mBoldType);
    

    Unfortunately there is no quick way to do this in the xml for custom fonts, but a properly programed Helper class should do what you need.

    If you need a example function let me know.

    What should be noted, is that if you set a custom typeface, things like android:fontStyle will not work, ie, you need a bold typeface, italic typeface etc..

提交回复
热议问题