If want to set text programmatically then use this method
Button
First you have to set button's property in XML
android:textAllCaps="false" // very important without this property might be it won't show effect
public SpannableString setSpanableString(String textString, int start, int end){
SpannableString spanString = new SpannableString(textString);
spanString.setSpan(new StyleSpan(Typeface.BOLD), start, end, 0);
return spanString;
}
Button btn; // get your button reference here
String text = "Hi, Dharmbir";
btn.setText(setSpanableString(text, 4, text.length));// set here your index
TextView
TextView tv; // get your TextView reference here
String text = "Hi, Dharmbir";
tv.setText(setSpanableString(text, 4, text.length));
Output
Hi, Dharmbir