Skip to content

Instantly share code, notes, and snippets.

@creativedrewy
Forked from izmajlowiczl/CustomDatePicker.java
Last active April 15, 2022 12:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creativedrewy/ae23e6a4c1f981d6642879f44599ba89 to your computer and use it in GitHub Desktop.
Save creativedrewy/ae23e6a4c1f981d6642879f44599ba89 to your computer and use it in GitHub Desktop.
Date/Time Picker fix for ScrollView - Kotlin
package com.myproject.myapp.myviews
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.DatePicker
/**
* Extended DatePicker to allow for year-selection scrolling within a scrollview
*/
class CustomDatePicker : DatePicker {
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 onInterceptTouchEvent(ev: MotionEvent): Boolean {
when (ev.actionMasked) {
MotionEvent.ACTION_DOWN -> parent?.requestDisallowInterceptTouchEvent(true)
}
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment