Giter VIP home page Giter VIP logo

keyboardlistener's Introduction

KeyboardListener

banner

facebook/react-native源码中抽离出来的用于监听Android软键盘弹出与收回事件的相关代码。

关于作者

景三,程序员,主要从事Android平台基础架构方面的工作,欢迎交流技术方面的问题,可以去我的Github提issue或者发邮件至[email protected]与我交流。

[TOC]

扫描二维码下载Demo

下载Demo的二维码

KeyboardListener-Demo.apk

一、效果演示

显示底部NavigationBar

图1 显示底部NavigationBar的情况
(注意“屏幕可用高度”的数值)

显示底部NavigationBar

图2 隐藏底部NavigationBar的情况
(注意“屏幕可用高度”的数值)

二、使用方法

可以直接把DisplayMetricsHolderGlobalLayoutListenerOnKeyboardChangedListener三个文件直接拷贝到你的工程里使用。

rootView.getViewTreeObserver().addOnGlobalLayoutListener(
        new GlobalLayoutListener(rootView, new OnKeyboardChangedListener() {
            /**
             * 键盘事件
             *
             * @param isShow         键盘是否展示
             * @param keyboardHeight 键盘高度(当isShow为false时,keyboardHeight=0)
             * @param screenWidth    屏幕宽度
             * @param screenHeight   屏幕可用高度(不包含底部虚拟键盘NavigationBar), 即屏幕高度-键盘高度(keyboardHeight)
             */
            @Override
            public void onChange(boolean isShow, int keyboardHeight, int screenWidth, int screenHeight) {
                // do sth.
            }
        }));

显示底部NavigationBar

三、更新日志

CHANGELOG.md

四、致谢

感谢facebook/react-native提供代码解决方案。

本仓库使用的react-native相关代码:

keyboardlistener's People

Contributors

relish-wang 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

Watchers

 avatar

keyboardlistener's Issues

关于fragment 里的监听

业务需求,在fragment 里监听就不是很灵光了,基本上第一次加载会有用,在操作 edittext 的时候监听就失效了

监听不到键盘事件

当设置全屏时,页面会监听不到键盘事件,:
//设置全屏;
WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; getWindow().setAttributes(lp); getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); //透明状态栏 setColor(Color.TRANSPARENT);
正在查问题,希望您也看一下。Google piexl2 9.0

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.