Skip to content

Instantly share code, notes, and snippets.

@orhanobut
Created August 9, 2017 11:27
Show Gist options
  • Save orhanobut/1e417607826d50bc115de6cee3baf065 to your computer and use it in GitHub Desktop.
Save orhanobut/1e417607826d50bc115de6cee3baf065 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="100dp"/>
public class MainActivity extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SpannableString spannable = new SpannableString("aasdfasasdfasdfasdf span span");
spannable.setSpan(
new LineBackgroundSpan() {
@Override public void drawBackground(Canvas c, Paint p, int left, int right, int top, int baseline, int bottom,
CharSequence text, int start, int end, int lnum) {
Log.d("Sample", lnum + "line called");
}
}, 19, 28, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
);
TextView textView = (TextView) findViewById(R.id.text);
textView.setText(spannable);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment