I have a button in my application. the text in the button goes as "Type: Location
" something like that.
I'm wondering whether its possible to change the text on the button as "Type: Location"
i.e Bold the text partially on the button??
Thanks for yoru time in advance.
Double tap the text you want to format. Tap Format, then choose a formatting option like bolding, italics, or changing the font color.
we have a more better choice like this :android:textStyle="bold"
android api support bold
Simply put your string in strings.xml and change it like this,
<string name="hello"><b>Hello</b> World, fh!</string>
and set this text to your button like this
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:text="@string/hello"
/>
Sometimes the above approach will not be helpful when you might have to use Dynamic Text. So at that case SpannableString comes into action.
String tempString="Copyright";
Button button=(Button)findViewById(R.id.button);
SpannableString spanString = new SpannableString(tempString);
spanString.setSpan(new StyleSpan(Typeface.BOLD), 0, spanString.length(), 0);
button.setText(spanString);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With