I am working on an android app using Android Studio.
Currently I am trying to figure out how to get a swipe detection to work, even if the cursor starts inside of an edittext.
I have followed the first answer here to get OnSwipeTouchListener to work. (It works outside of the main view - toasts show up saying "You have swiped left")
I call it using
var SV: ScrollView = findViewById(R.id.SV) as ScrollView
SV.setOnTouchListener(object:OnSwipeTouchListener(this@MainActivity) {
override fun onSwipeTop() {
Toast.makeText(this@MainActivity, "Top", Toast.LENGTH_SHORT).show()
println("TOP")
}
}
Where SV is my parent scroll view.
However, then I create an edittext programmatically and add it:
val myEditText = EditText(this)
linear.addView(myEditText)
Where linear is a child linearlayout inside the main scrollview
I cannot detect a swipe from inside the edittext to outside of it. It DOES work if you start on the outside, then swipe inside.
How can I detect swipes inside of edittexts, and swipes that start inside of an edittext, but end outside of it?
Can anyone help? Any help is appreciated!