- android NestedScrollView嵌套Edit
- NestedScrollView进入界面不能定位到顶部问题解决
- android的RecyclerView嵌套在NestedScr
- android解决RecyclerView嵌套在NestedSc
- NestedScrollView嵌套Recyclerview列表
- Android NestedScrollView 嵌套webvi
- Android NestedScrollView嵌套ViewPa
- Android NestedScrollView嵌套Recycl
- Android NestedScrollView嵌套Linear
- CoordinatorLayout CollapsingToo
处理思路: 监听NestedScrollView的滑动状态 当EditText 滑动到屏幕不可见时 让EditText 移除焦点
代码如下
nestedScrollView.setOnScrollChangeListener(object : NestedScrollView.OnScrollChangeListener {
override fun onScrollChange(v: NestedScrollView?, scrollX: Int, scrollY: Int, oldScrollX: Int, oldScrollY: Int) {
val p = Point()
windowManager.defaultDisplay.getSize(p)
val screenWidth = p.x
val screenHeight = p.y
val rect = Rect(0, 0, screenWidth, screenHeight)
val location = IntArray(2)
editText.getLocationInWindow(location)
if (editText.getLocalVisibleRect(rect)){
// 控件在屏幕可见区域
}else{
// 控件已不在屏幕可见区域,清除焦点
editText.clearFocus()
}
}
})
网友评论