I have a button in that i want two different text size to be displayed. i have declared that text into string.xml and i have set text in java code by btnSin.setText(getResources().getString(R.string.lblasin) + "\n"
+ getResources().getString(R.string.lblSin));
so what is the way to do so.
Asked
Active
Viewed 2,545 times
3

shivani patel
- 225
- 1
- 8
- 22
-
Same logic applies for buttons – Pragnani Mar 25 '13 at 05:38
-
http://stackoverflow.com/questions/12193785/different-textsizes-in-a-button this is what u were looking for. – bostan Mar 25 '13 at 05:46
2 Answers
5
SpannableStringBuilder spanSin = new SpannableStringBuilder();
SpannableString itemasin = new SpannableString(getResources().getString(R.string.lblasin)+"\n");
itemasin.setSpan(new AbsoluteSizeSpan(9, true), 0,itemasin.length(),0);
itemasin.setSpan(new ForegroundColorSpan(Color.parseColor("#EA7C07")), 0, itemasin.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spanSin.append(itemasin);
SpannableString itemsin = new SpannableString(getResources().getString(R.string.lblSin));
itemsin.setSpan(new AbsoluteSizeSpan(12, true), 0,itemsin.length(),0);
spanSin.append(itemsin);
btnSin.setText(spanSin,BufferType.SPANNABLE);

shivani patel
- 225
- 1
- 8
- 22