Use Roboto font for earlier devices

后端 未结 6 1067
说谎
说谎 2021-01-30 04:21

I would like to use the Roboto font in my Android application and make sure it works for earlier versions of Android that don\'t have the font installed. I know I can do this b

6条回答
  •  一个人的身影
    2021-01-30 05:26

    Retrieve all views inside activity, check its type and apply appropriate action.

    Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/Roboto/Roboto-Regular.ttf");
    for (View view : allViews)
    {
     if (view instanceof TextView) 
     {
        TextView textView = (TextView) view;
        textView.setTypeface(typeface);
      }
    }
    

提交回复
热议问题