【问题标题】:how to change font family of Tabhost in android如何在android中更改Tabhost的字体系列
【发布时间】:2015-07-11 09:10:46
【问题描述】:

我想将字体系列默认更改为我的字体系列。 这是可能的? 请帮帮我

谢谢。

【问题讨论】:

    标签: android fonts styles font-family


    【解决方案1】:

    设置字体等:

    for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) {
                    Typeface tf = Typeface.createFromAsset(this.getAssets(),"fonts/my_bolditalic.ttf");
                    final TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
                    tv.setTypeface(tf);
                    tv.setTextColor(Color.GREEN);
                    mTabHost.getTabWidget().getChildAt(i).setBackground(getResources().getDrawable(R.drawable.bg_tab_selector));
                }
    

    【讨论】:

      【解决方案2】:

      在资产文件夹中添加字体文件(.ttf、.ttc、.otf 等)
      set Fonts 是以编程方式进行的:

      TextView tv= (TextView)findViewById(R.id.custom);
      Typeface face=Typeface.createFromAsset(getAssets(), "fonts/heartbre.ttf");
      tv.setTypeface(face);
      

      【讨论】:

        【解决方案3】:
        textView.setTypeface(Typeface.createFromAsset(context.getAssets(), "SomeFont.ttf");
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-03-06
          • 2013-01-22
          相关资源
          最近更新 更多