LoginSignup
1
0

More than 3 years have passed since last update.

【Android】タップで切り替えを行わないSiwtchボタンの作成

Posted at

Switchボタンは通常タップもしくはフリックでON/OFFを切り替えを行う。
フリックのみでの切り替えを行いたい場合は以下を使用。

SwitchOnlyFlick.kt
class SwitchOnlyFlick : SwitchCompat {

    constructor(context: Context) : super(context)
    constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)

    override fun toggle() {}
}

toggle関数で何も行わないようにすれば、タップによるON/OFF切り替えは行われない。

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