I want increase font size of some part of the string before set to text view. Means My string is "Hello Stack over flow". Then I want font size of over is larger than other words and its bold.
            Asked
            
        
        
            Active
            
        
            Viewed 9,448 times
        
    2
            
            
        - 
                    1You can use Html.fromHtml(). – Piyush Mar 14 '14 at 07:29
- 
                    1You can use a Spannable String – Raghunandan Mar 14 '14 at 07:30
- 
                    http://stackoverflow.com/a/9842023/1937802 – Tamilselvan Kalimuthu Mar 14 '14 at 07:31
3 Answers
7
            Do something like below,
 String str="<small>Hello Stack</small><big>Over</big>flow";
 textview.setText(Html.fromHtml(str));
 
    
    
        Spring Breaker
        
- 8,233
- 3
- 36
- 60
6
            
            
        You can use a SpannableString
Example :
TextView tv = new TextView(this);
String string= "Hello";
String title="MyTitle";
SpannableString ss1=  new SpannableString(string);
ss1.setSpan(new RelativeSizeSpan(2f), 0, ss1.length(), 0);
tv.append(ss1);
tv.append(title);
setContentView(tv);
Snap

You may also check
Using size HTML attribute in TextView
Searching for supported html tags
http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html
http://bigknol.com/android-supported-html-tags-textview-string/
 
    
    
        Community
        
- 1
- 1
 
    
    
        Raghunandan
        
- 132,755
- 26
- 225
- 256
0
            
            
        you can use html string to make some part bold for example
private String getHtmlText(String boldString,String restString){
    String htmlString = "<b>" +boldString +"</b> "  + restString;
    return htmlString;
}
and then setText using Html.fromHtml(htmlString) like
  yourTextView.setText(Html.fromHtml(getHtmlText(textBold,textNormal)));
 
    
    
        maddy d
        
- 1,530
- 2
- 12
- 23
