Add ConsumedNestedScrollView

This commit is contained in:
Rafał Borcz 2019-08-02 20:11:08 +02:00
parent 292f0369b6
commit 7cccdc678d
2 changed files with 33 additions and 2 deletions

View file

@ -0,0 +1,31 @@
package io.github.wulkanowy.materialchipsinput
import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.core.widget.NestedScrollView
class ConsumedNestedScrollView : NestedScrollView {
constructor(context: Context) : super(context)
constructor(context: Context, attr: AttributeSet) : super(context, attr)
constructor(context: Context, attr: AttributeSet, defStyleAttr: Int) : super(context, attr, defStyleAttr)
override fun onNestedFling(target: View, velocityX: Float, velocityY: Float, consumed: Boolean): Boolean {
return super.onNestedFling(target, velocityX, velocityY, true)
}
override fun onNestedScroll(target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, type: Int) {
super.onNestedScroll(target, dxConsumed, dyConsumed, 0, 0, type)
}
override fun onNestedScroll(target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int) {
super.onNestedScroll(target, dxConsumed, dyConsumed, 0, 0)
}
override fun onNestedScroll(target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int, type: Int, consumed: IntArray) {
super.onNestedScroll(target, dxConsumed, dyConsumed, 0, 0, type, consumed)
}
}

View file

@ -5,7 +5,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.core.widget.NestedScrollView
<io.github.wulkanowy.materialchipsinput.ConsumedNestedScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -41,5 +41,5 @@
tools:ignore="Autofill,LabelFor,TextFields" />
</LinearLayout>
</FrameLayout>
</androidx.core.widget.NestedScrollView>
</io.github.wulkanowy.materialchipsinput.ConsumedNestedScrollView>
</LinearLayout>