Need help with KulaKeyboard?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

FreddyChen
149 Stars 22 Forks Apache License 2.0 49 Commits 5 Opened issues

Services available

!
?

Need anything else?

Contributors list

# 13,832
Java
aio
nio
Kotlin
23 commits

KulaKeyboard

Android仿微信键盘输入法/表情/更多面板切换

效果展示

  • 微信
    微信效果展示
  • KulaKeyboard
    KulaKeyboard效果展示

使用方式

  1. 添加依赖
    在app build.gradle添加以下代码:

    implementation 'com.freddy:kulakeyboard_lib:1.0.1'   
    
  2. AndroidManifest.xml
    设置对应的
    activity
    节点
    android:windowSoftInputMode="adjustNothing"
    或在
    Activity setContentView()之前调用window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING)
  3. 自定义输入法面板(参考

    CInputPanel
    )、表情面板(参考
    CExpressionPanel
    )、更多面板(参考
    CMorePanel
    )。
  4. 初始化

    KeyboardHelper
    并绑定对应自定义Panel及设置获取到的键盘高度等 ``` private lateinit var keyboardHelper: KeyboardHelper keyboardHelper = KeyboardHelper() keyboardHelper.init(this) .bindRootLayout(layoutmain) .bindBodyLayout(layoutbody) .bindInputPanel(chatinputpanel) .bindExpressionPanel(expressionpanel) .bindMorePanel(morepanel) .setKeyboardHeight( if (App.instance.keyboardHeight == 0) DensityUtil.getScreenHeight(applicationContext) / 5 * 2 else App.instance.keyboardHeight ) .setOnKeyboardStateListener(object : KeyboardHelper.OnKeyboardStateListener { override fun onOpened(keyboardHeight: Int) { App.instance.keyboardHeight = keyboardHeight }
            override fun onClosed() {
            }
        })
    
    **注:如果应用有登录页面,可在用户登录弹出软键盘时获取键盘高度并保存到本地,方便下次使用。如果没有登录页面,则可以选择首次设置键盘高度为某个值,比如屏高度的2/5,这样在第一次弹出软键盘或面板时,或存在高度显示的瑕疵,在弹出键盘后,即获取到键盘高度,此时`KulaKeyboard库`会自动更新对应的值,后续会显示正确。目前Android系统并不提供直接获取键盘高度的方式,只能这样处理。考虑到一半社交App都需要登录,或在其它页面弹出软键盘时及时更新本地保存的键盘高度的值即可,影响不大。**
    

以上步骤即可。

另外,贴上Activity布局文件,仅供参考 ``` <?xml version="1.0" encoding="utf-8"?>

<linearlayout android:id="@+id/layout_body" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">

    <androidx.recyclerview.widget.recyclerview android:id="@+id/recycler_view" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="#333333"></androidx.recyclerview.widget.recyclerview>

    <com.freddy.kulakeyboard.sample.cinputpanel android:id="@+id/chat_input_panel" android:layout_width="match_parent" android:layout_height="wrap_content"></com.freddy.kulakeyboard.sample.cinputpanel>
</linearlayout>

<com.freddy.kulakeyboard.sample.cexpressionpanel android:id="@+id/expression_panel" android:layout_width="match_parent" android:layout_height="wrap_content" android:visibility="invisible"></com.freddy.kulakeyboard.sample.cexpressionpanel>

<com.freddy.kulakeyboard.sample.cmorepanel android:id="@+id/more_panel" android:layout_width="match_parent" android:layout_height="wrap_content" android:visibility="invisible"></com.freddy.kulakeyboard.sample.cmorepanel>

```

使用过程中,如果有任何疑问,请联系我。

开源不易。如果该项目对你有帮助,麻烦点个star鼓励一下作者。另外,欢迎fork和pr,让我们共同完善。

QQ交流群:1015178804,目前是Android IM技术交流群,后续写的文章,也会用此群进行交流。

最新新开了一个微信公众号,方便后续KulaChat发布一些系列文章,同时也是为了激励自己写作。主要发布一些原创的Android IM相关的文章(也会包含其它方向),不定时更新。感兴趣的同学可以关注一下,谢谢。PS:感觉鸿洋大神提供的公众号文章排版方式,感激不尽~~

FreddyChen的微信公众号

License

Copyright 2020, chenshichao

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.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.