I am looking for a textview which looks like . I have used below code for the implementation of this..
SpannableString text;
text = new SpannableString(bal_dollars.getText());
int index = bal_dollars.getText().toString().indexOf(".");
text.setSpan(new TextAppearanceSpan(getApplicationContext(),
R.style.HeroGraphicBalanceSmallFont), index, bal_dollars
.getText().toString().length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
bal_dollars.setText(text, TextView.BufferType.SPANNABLE);
here is the style used in the span..
<style name="HeroGraphicBalanceSmallFont" parent="@android:style/TextAppearance.Medium">
<item name="android:layout_width">wrap_content</item>
<item name="android:textSize">50sp</item>
<item name="android:singleLine">true</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_gravity">top|right</item>
<item name="android:paddingBottom">30dp</item>
<item name="android:gravity">top|right</item>
<item name="android:textColor">@color/status_text</item>
<item name="customFont">fonts/HeroicCondensedMedium.ttf</item>
</style>
everything looks fine except the spacing of targeted span of text i.e decimal part gravity.. . I tried all the xml attributes. Please help
I cracked it. I am posting this as it might be helpful for others and thanks to @kcoppock for the hint. I have extended
MetricAffectingSpan
class which affects character-level text formatting in a way that changes the width or height of characters extend this class.use this to update the text in your views..