How to make RelativeSizeSpan align to top

However I did in this way: activity_main.xml: <TextView android:id=”@+id/txtView” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_marginTop=”50dp” android:textSize=”26sp” /> MainActivity.java: TextView txtView = (TextView) findViewById(R.id.txtView); SpannableString spannableString = new SpannableString(“RM123.456”); spannableString.setSpan( new TopAlignSuperscriptSpan( (float)0.35 ), 0, 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE ); txtView.setText(spannableString); TopAlignSuperscriptSpan.java: private class TopAlignSuperscriptSpan extends SuperscriptSpan { //divide superscript by this number protected int fontScale = 2; //shift value, 0 … Read more

Android SpannableString set background behind part of text

If anyone’s having difficulty with Roosevelt’s code sample (I sure was, maybe because it’s Xamarin.Android?), here’s a translation into a more basic Android java version: public class RoundedBackgroundSpan extends ReplacementSpan { private static int CORNER_RADIUS = 8; private int backgroundColor = 0; private int textColor = 0; public RoundedBackgroundSpan(Context context) { super(); backgroundColor = context.getResources().getColor(R.color.gray); … Read more

SpannableString: Is it possible to apply two or more RelativeSizeSpans?

If you’re still looking for an answer, I might have a solution. I had similar problems. I used TextUtils to concat the 2 SpannableString. Here is some example code: SpannableString span1 = new SpannableString(“32m”); SpannableString span2 = new SpannableString(“50s”); span1.setSpan(new RelativeSizeSpan(0.75f), 2, 3, 0); span2.setSpan(new RelativeSizeSpan(0.75f), 2, 3, 0); mTextView.setText(TextUtils.concat(span1,” ” ,span2));

How to set multiple spans on a TextView’s text on the same partial text?

Simply set additional spans. They are going to overlap/merge when neccessary. This code works for me: final SpannableString text = new SpannableString(“Hello stackOverflow”); text.setSpan(new RelativeSizeSpan(1.5f), text.length() – “stackOverflow”.length(), text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); text.setSpan(new ForegroundColorSpan(Color.RED), 3, text.length() – 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); tv.setText(text);

SpannableStringBuilder to create String with multiple fonts/text sizes etc Example?

First Part Not Bold BOLD rest not bold You can do this either as @Rajesh suggested or by this. String normalBefore= “First Part Not Bold “; String normalBOLD= “BOLD “; String normalAfter= “rest not bold”; String finalString= normalBefore+normalBOLD+normalAfter; Spannable sb = new SpannableString( finalString ); sb.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), finalString.indexOf(normalBOLD)+ normalBOLD.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); //bold sb.setSpan(new AbsoluteSizeSpan(intSize), finalString.indexOf(normalBOLD)+ normalBOLD.length(), … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)