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

Links in TextView

Thank you for your help all. I have managed to make this work, after I have found some examples in the android samples. here is the code: textView.setText(Html.fromHtml( “<b>text3:</b> Text with a ” + “<a href=\”http://www.google.com\”>link</a> ” + “created in the Java source code using HTML.”)); textView.setMovementMethod(LinkMovementMethod.getInstance()); Hope this help others…

What is meant by Ems? (Android TextView)

android:ems or setEms(n) sets the width of a TextView to fit a text of n ‘M’ letters regardless of the actual text extension and text size. See wikipedia Em unit but only when the layout_width is set to “wrap_content”. Other layout_width values override the ems width setting. Adding an android:textSize attribute determines the physical width … Read more

How to Show Circular Text using TextView in Android

you can try this tested and full working code : public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new GraphicsView(this)); } static public class GraphicsView extends View { private static final String QUOTE = “This is a curved text”; private Path circle; private Paint cPaint; private Paint tPaint; public GraphicsView(Context … Read more

How to change fragment’s textView’s text from activity

You can find the instance of Fragment by using, For support library, YourFragment fragment_obj = (YourFragment)getSupportFragmentManager(). findFragmentById(R.id.fragment_id); else YourFragment fragment_obj = (YourFragment)getFragmentManager(). findFragmentById(R.id.fragment_id); Then create a method in the Fragment that updates your TextView and call that method using fragment_obj like, fragment_obj.updateTextView();