I have a textview ,that contains different texts that can set dynamically.
different string likes
String s1="I am a Good boy";
String s2="I am a Bad` boy";
TextView tvnotificationstype=(TextView)view.findViewById(R.id.tv_notificationstype);
I using spanable but didnot get result
Typeface fontbold = Typeface.createFromAsset(context.getAssets(), "fonts/SourceSansPro-Bold.ttf");
String[] sentence = s1.split(" ");
for(String word: sentence)
{
if(word.contains("Good"))
{
Spannable spannable = new SpannableString(word);
spannable.setSpan(fontbold , 0, 4, 0);
tvnotificationstype.setText("I"+" "+"am"+" "+"a"+" "+spannable+"boy");
}
}
I am using above code but i did not get the custom font effect .so please help me is there any mistake the above code.advance thanks for all