安卓键盘面板冲突解决方案 JKeyboardPanelSwitch

码农软件 · 软件分类 · Android UI 组件 · 2019-04-25 07:27:26

软件介绍

JKeyboardPanelSwitch是一款用于Android键盘面板冲突,布局闪动处理方案的软件。

效果对比

如何使用

build.gradle中:

compile 'cn.dreamtobe.kpswitch:library:1.3.0'

对应的Activity,在Manifest中配置android:windowSoftInputMode=adjustResize:

<manifest
  ...>
  <application
    ...>
    <activity
      android:name=".activity.ChattingActivity"
      android:windowSoftInputMode=adjustResize"/>
      ...
  </application>
  ...
</manifest>

在面板页面的layout中:

<?xml version="1.0" encoding="utf-8"?>
<cn.dreamtobe.kpswitch.widget.CustomRootLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <!-- 布局内容 -->
    ...
    <cn.dreamtobe.kpswitch.widget.PanelLayout
        android:id="@+id/panel_root"
        android:layout_width="fill_parent"
        android:layout_height="@dimen/panel_height"
        android:visibility="gone">
        <!-- 面板内容 -->
        ...
    </cn.dreamtobe.kpswitch.widget.PanelLayout>
</cn.dreamtobe.kpswitch.widget.CustomRootLayout>

在Activity中:

...
private PanelLayout mPanelLayout;
// 任何的可以用于收键盘输入的View,可有可无,用于显示keyboard的时候传入
private EditText mSendEdt;
@Override
public void onCreate(Bundle saveInstanceState){
    ...
    mPanelLayout = (PanelLayout)findViewById(R.id.panel_root)
}
...
// Keyboard与面板相互切换
public void switchPanel(){
    if (mPanelLayout.getVisibility() == View.VISIBLE){
        KeyboardUtil.showKeyboard(mSendEdt);
    } else {
        KeyboardUtil.hideKeyboard(mSendEdt);
        showPanel()
    }
}
public void hidePanel(){
    mPanelLayout.setVisibility(View.GONE);
}
public void showPanel(){
    mPanelLayout.setVisibility(View.VISIBLE);
}
...
// 如果需要处理返回收起面板的话
@Override
public boolean dispatchKeyEvent(KeyEvent event){
    if (event.getAction() == KeyEvent.ACTION_UP &&
            event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
        if (mPanelLayout.getVisibility() == View.VISIBLE) {
            hidePanel();
            return true;
        }
    }
    return super.dispatchKeyEvent(event);
}

本文地址:https://codercto.com/soft/d/4330.html

嵌入式系统软件设计中的常用算法

嵌入式系统软件设计中的常用算法

周航慈 / 2010-1 / 24.00元

《嵌入式系统软件设计中的常用算法》根据嵌入式系统软件设计需要的常用算法知识编写而成。基本内容有:线性方程组求解、代数插值和曲线拟合、数值积分、能谱处理、数字滤波、数理统计、自动控制、数据排序、数据压缩和检错纠错等常用算法。从嵌入式系统的实际应用出发,用通俗易懂的语言代替枯燥难懂的数学推导,使读者能在比较轻松的条件下学到最基本的常用算法,并为继续学习其他算法打下基础。 《嵌入式系统软件设计中的......一起来看看 《嵌入式系统软件设计中的常用算法》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换