LoginSignup
2
1

More than 5 years have passed since last update.

kotlinでtextViewに指定する色をcolor.xmlから取得して一部変更する方法

Last updated at Posted at 2016-02-04

textViewオブジェクト:textSample

filename
val colorStr = Color.parseColor("#" + Integer.toHexString(context.resources.getColor(R.color.color_sample1)))
val txtStr = "This is a <font color="+colorStr+">sample.</font>"
textSample.text = Html.fromHtml(txtStr)

結果: This is a sample.

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1