-
-
Save creativedrewy/ae23e6a4c1f981d6642879f44599ba89 to your computer and use it in GitHub Desktop.
Date/Time Picker fix for ScrollView - Kotlin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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