修改手机系统显示大小,注册键盘挡住输入框的bug
This commit is contained in:
@@ -232,8 +232,12 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
|
||||
* 监听键盘弹出和隐藏,解决键盘弹出挡住输入框的问题
|
||||
*/
|
||||
fun setListenKeyboardChange(windowTranslateY: Int = 500, view: View = window.decorView) {
|
||||
val metrics = getResources().displayMetrics
|
||||
val screenWidth = metrics.widthPixels
|
||||
// val screenHeight = metrics.heightPixels
|
||||
val scaleFactor = screenWidth / 1080 // 假设 1080 是设计宽度
|
||||
window.decorView.viewTreeObserver.addOnGlobalLayoutListener {
|
||||
onLayoutChange(view, windowTranslateY)
|
||||
onLayoutChange(view, windowTranslateY * scaleFactor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user