1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[Android]アクションバーの色を動的に変える

Posted at

アクションバーの色を変更する

MainActivity.kt
supportActionBar?.setBackgroundDrawable(ColorDrawable(Color.parseColor("カラーコード")))

ステータスバーの色を変更する

MainActivity.kt
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = Color.parseColor("カラーコード")

アプリをAPIバージョンの22以下に対応させる場合、ステータスバーの文字色が白色に固定されているため、ステータスバーの色が白系統の場合文字の可読性を損なわないか考慮する必要があります.

ツールバーの色を変更する

MainActivity.kt
toolbar.setBackgroundColor(Color.parseColor("カラーコード"))
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?