安卓键盘面板冲突解决方案 JKeyboardPanelSwitch
- 授权协议: Apache-2.0
- 开发语言: Java
- 操作系统: Android
- 软件首页: https://github.com/Jacksgong/JKeyboardPanelSwitch
- 软件文档: https://github.com/Jacksgong/JKeyboardPanelSwitch
- 官方下载: https://github.com/Jacksgong/JKeyboardPanelSwitch.git
软件介绍
JKeyboardPanelSwitch是一款用于
效果对比
如何使用
在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);
}
宇宙涟漪中的孩子
谢云宁 / 四川科学技术出版社 / 2017-11 / 28.00元
近未来。日冕科技公司通过建造围绕太阳的光幕搜集了近乎无穷的能源,这些能源主要用于地球上的网络空间建设。随着全球网络时间频率的不断提升,越来越多的人选择接驳进虚拟空间,体验现实中难以经历的丰富人生。 网络互动小说作者宁天穹一直自认为是这些人中普通的一员,有一天却被一名读者带进反抗组织,了解到日冕公司的各种秘密,并被告知自己的小说将在抵抗运动中起到重要作用。 起初他拒绝参与,但看到地球被笼......一起来看看 《宇宙涟漪中的孩子》 这本书的介绍吧!
