Created
August 9, 2017 11:27
-
-
Save orhanobut/1e417607826d50bc115de6cee3baf065 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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