title: Set custom font to dynamically added text view android
body: <p>I am adding a TextView to a LinearLayout at run time.<br>
  I want to set a font at run time from my <code>assets/fonts/</code> folder.<br>
  I have done the following, but it is not working:</p>
  
  <pre><code>private ArrayList&lt;TextView&gt; getExperTextViews() {
      ArrayList&lt;TextView&gt; textViewArrayList = new ArrayList&lt;&gt;();
      TextView tv_title = new TextView(DesignerDetailActivity.this);
      LinearLayout.LayoutParams parms = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
              LinearLayout.LayoutParams.WRAP_CONTENT);
      parms.setMargins(0,0,0,5);
      tv_title.setLayoutParams(parms);
      Typeface font=Typeface.createFromAsset(getAssets(), "fonts/OpenSans-Bold.ttf");
      tv_title.setTypeface(font);
      tv_title.setText("EXPERTISE");
  
      tv_title.setTextSize(16);
  
      textViewArrayList.add(tv_title);
      ArrayList&lt;DesignerExpertise&gt; designerExpertiseArrayList = designer.getExpertiseArrayList();
  
  
      String expertiseString = "&lt;font color='#a8a8a8'&gt;{property}&lt;/font&gt; &amp;nbsp;";
      for (int i = 0; i &lt; designerExpertiseArrayList.size(); i++) {
          TextView tv = new TextView(DesignerDetailActivity.this);
          tv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                  LinearLayout.LayoutParams.WRAP_CONTENT));
          DesignerExpertise designerExpertise = designerExpertiseArrayList.get(i);
          ArrayList&lt;DesignerExpertiseValue&gt; designerExpertiseValueArrayList = designerExpertise.getDesignerExpertiseValues();
  
          String newExpertiseString = expertiseString.replace("{property}", designerExpertise.getProperty().toUpperCase());
          newExpertiseString = newExpertiseString + designerExpertiseValueArrayList.get(0).getName();
          for (int j = 1; j &lt; designerExpertiseValueArrayList.size(); j++) {
              newExpertiseString = newExpertiseString + " ," + designerExpertiseValueArrayList.get(1).getName();
          }
          Typeface _font=Typeface.createFromAsset(getAssets(), "fonts/OpenSans-Regular.ttf");
          tv_title.setTypeface(_font);
  
          tv.setText(Html.fromHtml(newExpertiseString), TextView.BufferType.SPANNABLE);
          tv.setTextSize(16);
          tv.setPadding(0,5,0,5);
          textViewArrayList.add(tv);
      }
      return textViewArrayList;
  }
  </code></pre>
  
  <p>Please, help me.</p>