Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/liangjingkanji/soft-input-event
Android软键盘遮挡/平滑动画最佳解决方案 Solution for keyboard cover in/smooth animation
https://github.com/liangjingkanji/soft-input-event
android animation keyboard-events softinput windowinsets
Last synced: about 14 hours ago
JSON representation
Android软键盘遮挡/平滑动画最佳解决方案 Solution for keyboard cover in/smooth animation
- Host: GitHub
- URL: https://github.com/liangjingkanji/soft-input-event
- Owner: liangjingkanji
- License: apache-2.0
- Created: 2022-05-04T19:21:59.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-09-07T04:55:53.000Z (about 1 year ago)
- Last Synced: 2023-11-07T16:00:47.025Z (about 1 year ago)
- Topics: android, animation, keyboard-events, softinput, windowinsets
- Language: Kotlin
- Homepage:
- Size: 23.1 MB
- Stars: 234
- Watchers: 7
- Forks: 25
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Android软键盘最佳解决方案
不同于其他同类型框架, 本框架使用Android11推出的新功能`WindowInsetsAnimation`来解决软键盘相关问题, 具备软键盘平滑过渡动画(部分机型可能不支持), 提供更准确的软键盘Api以及软键盘遮挡解决方案
如果遇到机型兼容问题请反馈或者发起修复PR
欢迎贡献代码/问题
## 特点
- [x] 软键盘显示隐藏使用平滑动画过渡
- [x] 指定视图悬浮于软键盘上
- [x] 更准确的软键盘高度/显示隐藏监听
- [x] 指定监听输入框
- [x] 显示/隐藏软键盘
- [x] 支持对话框
- [x] 更简单易用的方法## 使用
监听键盘显示或者指定视图悬浮于软键盘上只需要一个方法
本方法支持`Activity/Fragment/Dialog/DialogFragment/BottomSheetDialogFragment`
```kotlin
setWindowSoftInput(
float = llInput,
onChanged = {
Log.d("SoftInput", "visibility = ${hasSoftInput()}")
}
)
```| 方法 | 描述 |
| --------------------------- | ----------------------- |
| setWindowSoftInput | 软键盘遮挡/监听显示隐藏 |
| showSoftInput/hideSoftInput | 显示隐藏软键盘 |
| hasSoftInput | 当前是否有软键盘 |
| getSoftInputHeight | 当前软键盘高度 |## 安装
Project 的 settings.gradle 添加仓库
```kotlin
dependencyResolutionManagement {
repositories {
// ...
maven { url 'https://jitpack.io' }
}
}
```Module 的 build.gradle 添加依赖框架
```groovy
dependencies {
implementation 'com.github.liangjingkanji:soft-input-event:1.0.9'
}
```## License
```
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```