LoginSignup
1
0

More than 3 years have passed since last update.

[Android/Kotlin]コードからtextViewに取り消し線を付ける

Last updated at Posted at 2020-09-23

結論

kotlin
textView.paint.flags = textView.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG // 取り消し線
xml
<TextView
    android:id="@+id/textView"/>

textView.paint.flags = Paint.STRIKE_THRU_TEXT_FLAGだけだとアンチエイリアスが切れてギザギザになる

別解

paint.flagspaintFlagsでもいいらしい

kotlin
textView.paintFlags = textView.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG // 取り消し線

取り消し線とアンチエイリアスは個別に指定しても良さそう

kotlin
textView.paint.flags = Paint.STRIKE_THRU_TEXT_FLAG // 取り消し線
textView.paint.isAntiAlias = true // アンチエイリアス

その他

STRIKE_THRU_TEXT_FLAGのところ変えれば下線とかもできる

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