Giter Club home page Giter Club logo

soft-input-event's Introduction

Android软键盘最佳解决方案

下载体验 | 兼容问题


不同于其他同类型框架, 本框架使用Android11推出的新功能WindowInsetsAnimation来解决软键盘相关问题, 具备软键盘平滑过渡动画(部分机型可能不支持), 提供更准确的软键盘Api以及软键盘遮挡解决方案


如果遇到机型兼容问题请反馈或者发起修复PR

欢迎贡献代码/问题

特点

  • 软键盘显示隐藏使用平滑动画过渡
  • 指定视图悬浮于软键盘上
  • 更准确的软键盘高度/显示隐藏监听
  • 指定监听输入框
  • 显示/隐藏软键盘
  • 支持对话框
  • 更简单易用的方法

使用

监听键盘显示或者指定视图悬浮于软键盘上只需要一个方法

本方法支持Activity/Fragment/Dialog/DialogFragment/BottomSheetDialogFragment

setWindowSoftInput(
    float = llInput,
    onChanged = {
        Log.d("SoftInput", "visibility = ${hasSoftInput()}")
    }
)
方法 描述
setWindowSoftInput 软键盘遮挡/监听显示隐藏
showSoftInput/hideSoftInput 显示隐藏软键盘
hasSoftInput 当前是否有软键盘
getSoftInputHeight 当前软键盘高度

安装

Project 的 settings.gradle 添加仓库

dependencyResolutionManagement {
    repositories {
        // ...
        maven { url 'https://jitpack.io' }
    }
}

Module 的 build.gradle 添加依赖框架

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 at

http://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.

soft-input-event's People

Contributors

liangjingkanji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

soft-input-event's Issues

华为机型无效

试了下Demo,在华为Mate 30 Pro(鸿蒙2.0 & Android 10)上无效,vivo x60(Android 11)可用。

SVID_20220506_141238_1.mp4

google material的依赖?

问题描述

这个库会自动添加google material的dependency

期望行为

移除该dependency,要不然软件之间暴增400k

CoordinatorLayout 布局里面设置了layout_behavior 华为畅享系列手机不兼容

问题描述

CoordinatorLayout 布局里面设置了layout_behavior 华为畅享系列手机只要输入换行符,输入框就已经是隐藏键盘状态了,但是键盘还是在现实

期望行为

希望在输入过程中有回车换行也不要下移输入框体验很不好

如何复现

fork仓库并复现问题可以快速解决, 猜测只会让问题晦涩难懂, 耽误所有人时间

截图

异常堆栈信息或者手机截图/视频(拖拽到输入框即可上传)

版本

  • soft-input-event: 1.0.9
  • Android:
  • 设备型号: 畅享50、畅享70x

setWindowSoftInput Problem

setWindowSoft Input(binding.price EditText,binding.root) I use the above code for a button and it works fine, but when I click on another edittexe in the same fragment, the screen scrolls completely.

How can we solve this?

https://i.hizliresim.com/ssn2fzz.gif

  • soft-input-event: 1.0.9
  • Android: API 28

如果输入框在上方,用这个方法会强行把输入框拉下来,上面一片空白

问题描述

输入框edittext放在屏幕上方即可明显复现,有标题栏的话看的更清楚

期望行为

如何复现

输入框edittext放在屏幕上方即可明显复现,有标题栏的话看的更清楚。
在你的demo上修改布局,把输入框放到recyclerview的上面,此时输入框在顶部,按理说是不需要因为弹出键盘而被拉下来的。
不然就会出现类似这种很奇怪的页面
image
我正在编辑身份证号这一栏,本来这个输入框是在上面的,不需要被输入框拉下来,这样上面多出了一块不正常的空白区域,使用recyclerview或scrollview+LinearLayout都会有同样的问题

fork仓库并复现问题可以快速解决, 猜测只会让问题晦涩难懂, 耽误所有人时间

截图

异常堆栈信息或者手机截图/视频(拖拽到输入框即可上传)

版本

  • soft-input-event:最新版本。设备:所有机型设备都一样的情况,找屏幕大的,看的比较明显
  • Android:
  • 设备型号:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.