How to align TextView around an ImageView?

You can achieve this by using the android.text.style.LeadingMarginSpan.LeadingMarginSpan2 interface which is available in API 8. Here is the article, not in English though, translate it using your browser. Besides you can download the source code of the example directly from here. Your layout: <?xml version=”1.0″ encoding=”UTF-8″?> <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:padding=”5dp”> <TextView android:textSize=”18.0sp” android:id=”@+id/message_view” android:layout_width=”match_parent” … Read more

How to break styled text into pages in Android?

UPDATE: I created sample application, that shows how to use PageSplitter. How it works? Example application (Russian) – Cleverum. You need only PageSplitter class. Other code shows you how to use this class. import android.graphics.Typeface; import android.text.SpannableString; import android.text.SpannableStringBuilder; import android.text.TextPaint; import android.text.style.StyleSpan; import java.util.ArrayList; import java.util.List; public class PageSplitter { private final int pageWidth; … Read more

Android Linkify text – Spannable Text in Single Text View – As like Twitter tweet

What you can do is create a Custom ClickableSpan as below, class MyCustomSpannable extends ClickableSpan { String Url; public MyCustomSpannable(String Url) { this.Url = Url; } @Override public void updateDrawState(TextPaint ds) { // Customize your Text Look if required ds.setColor(Color.YELLOW); ds.setFakeBoldText(true); ds.setStrikeThruText(true); ds.setTypeface(Typeface.SERIF); ds.setUnderlineText(true); ds.setShadowLayer(10, 1, 1, Color.WHITE); ds.setTextSize(15); } @Override public void onClick(View widget) … 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

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