How to change action bar title color in code

前端 未结 6 1268
陌清茗
陌清茗 2020-11-27 05:28

I\'m having trouble changing androids action bar title color programmatically for v11 and up. I can get it done in xml but need to change it dynamically in code. How should

6条回答
  •  自闭症患者
    2020-11-27 06:17

    Using Kotlin and SupportActionBar Use this ->

    val mSpannableText = SpannableString(supportActionBar?.title)
        mSpannableText.setSpan(
            ForegroundColorSpan(Color.BLUE),
            0,
            mSpannableText.length,
            Spannable.SPAN_INCLUSIVE_INCLUSIVE
        )
        supportActionBar?.title = mSpannableText
    

提交回复
热议问题