Arial font for text in Android

后端 未结 6 1522
悲哀的现实
悲哀的现实 2021-02-20 04:11

I want to show text in Arial font. But Arial font is not available in android system fonts. I don\'t want to use arial ttf file in my application. Is there any other way to appl

6条回答
  •  自闭症患者
    2021-02-20 04:48

    Create a TextView from Java Code or XML like this

    
    
    

    Make sure to keep the id as it is here because the TabLayout check for this ID if you use custom textview

    Then from code inflate this layout and set the custom Typeface on that textview and add this custom view to the tab

    for (int i = 0; i < tabLayout.getTabCount(); i++) {
        //noinspection ConstantConditions
     TextView tv=(TextView)LayoutInflater.from(this).inflate(R.layout.custom_tab,null)
     tv.setTypeface(Typeface);       
     tabLayout.getTabAt(i).setCustomView(tv);
    
    }
    

提交回复
热议问题