getString(R.string.what_is_android) val spannableStringBuilder = SpannableStringBuilder() spannableStringBuilder.append(firstPart) spannableStringBuilder.append("\n") spannableStringBuilder.setSpan( StyleSpan(Typeface.BOLD), 0, firstPart.length, Spannable.SPAN_INCLUSIVE_INCLUSIVE ) spannableStringBuilder.setSpan( RelativeSizeSpan(2f), 0, firstPart.length, Spannable.SPAN_INCLUSIVE_INCLUSIVE ) spannableStringBuilder.setSpan( ForegroundColorSpan(Color.WHITE), 0, firstPart.length, Spannable.SPAN_INCLUSIVE_INCLUSIVE ) val secondPart = getString(R.string.what_is_android_answer) spannableStringBuilder.append(secondPart) spannableStringBuilder.setSpan( ForegroundColorSpan( ContextCompat.getColor( this@MainActivity, R.color.colorAccent ) ), firstPart.length, firstPart.length + secondPart.length, Spannable.SPAN_EXCLUSIVE_INCLUSIVE ) spannableStringBuilder.append("\n") val thirdPart = getString(R.string.faq) } spannableStringBuilder.append(thirdPart) spannableStringBuilder.setSpan( ForegroundColorSpan( ContextCompat.getColor( this@MainActivity, R.color.dirty_white ) ), beginning, ending, Spannable.SPAN_EXCLUSIVE_INCLUSIVE ) spannableStringBuilder.append(" ") val clickableText = "Android website." spannableStringBuilder.append(clickableText) spannableStringBuilder.setSpan( object : ClickableSpan() { override fun onClick(widget: View) { //open webview val url = getString(R.string.android_website) startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url))) } override fun updateDrawState(ds: TextPaint) { super.updateDrawState(ds) ds.isUnderlineText = true } }, spannableStringBuilder.length - clickableText.length, spannableStringBuilder.length, Spannable.SPAN_INCLUSIVE_INCLUSIVE ) spannableStringBuilder.setSpan( ForegroundColorSpan(Color.GREEN), spannableStringBuilder.length - clickableText.length, spannableStringBuilder.length, Spannable.SPAN_INCLUSIVE_INCLUSIVE ) return spannableStringBuilder }