Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/GitPhoenix/KeyboardView
自定义安全键盘
https://github.com/GitPhoenix/KeyboardView
Last synced: about 24 hours ago
JSON representation
自定义安全键盘
- Host: GitHub
- URL: https://github.com/GitPhoenix/KeyboardView
- Owner: GitPhoenix
- License: apache-2.0
- Created: 2016-12-18T11:02:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2016-12-19T03:10:02.000Z (over 7 years ago)
- Last Synced: 2024-02-29T03:37:48.933Z (4 months ago)
- Language: Java
- Size: 202 KB
- Stars: 109
- Watchers: 5
- Forks: 27
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-github-android-ui - KeyboardView - 自定义安全键盘 (软键盘)
- awesome-github-android-ui - KeyboardView - 自定义安全键盘 (软键盘)
README
# KeyboardView 自定义安全键盘
######效果图:![keyboardView](https://github.com/GitPhoenix/KeyboardView/blob/master/art/keyboardView.gif)具体使用
```
editView.setEditView(llKeyboard, keyboardView, true);editView.setOnKeyboardListener(new EditView.OnKeyboardListener() {
@Override
public void onHide(boolean isCompleted) {
if (height > 0) {
llGuan.scrollBy(0, -(height + DensityUtil.dp2px(MainActivity.this, 16)));
}if (isCompleted) {
Log.i("", "你点击了完成按钮");
}
}@Override
public void onShow() {
llGuan.post(new Runnable() {
@Override
public void run() {
//pos[0]: X,pos[1]: Y
int[] pos = new int[2];
//获取编辑框在整个屏幕中的坐标
editView.getLocationOnScreen(pos);
//编辑框的Bottom坐标和键盘Top坐标的差
height = (pos[1] + editView.getHeight())
- (ScreenUtil.getScreenHeight(MainActivity.this) - keyboardView.getHeight());
if (height > 0) {
//编辑框和键盘之间预留出16dp的距离
llGuan.scrollBy(0, height + DensityUtil.dp2px(MainActivity.this, 16));
}
}
});
}@Override
public void onPress(int primaryCode) {}
});
```
llKeyboard为包裹键盘的父布局,llGuan为包裹输入框的父布局。