module链接:https://download.csdn.net/download/meixi_android/10652565
compile project(':edlibrary')
, ':edlibrary'
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:id="@+id/root_view"android:orientation="vertical"><ScrollViewandroid:id="@+id/sv_main"android:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"><LinearLayoutandroid:id="@+id/all_ed"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"><EditTextandroid:id="@+id/normal_ed"android:layout_width="match_parent"android:layout_height="wrap_content"android:hint="普通键盘" /><EditTextandroid:id="@+id/special_ed"android:layout_width="match_parent"android:layout_height="wrap_content"android:hint="特殊键盘"android:inputType="numberPassword"/></LinearLayout></ScrollView>
</LinearLayout>
private LinearLayout rootView;
private ScrollView scrollView;private EditText specialEd;
private KeyboardUtil keyboardUtil;
@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);rootView = (LinearLayout) findViewById(R.id.root_view);scrollView = (ScrollView) findViewById(R.id.sv_main);specialEd = (EditText) findViewById(R.id.special_ed);initMoveKeyBoard();}@Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) {if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 ) {if(keyboardUtil.isShow){keyboardUtil.hideSystemKeyBoard();keyboardUtil.hideAllKeyBoard();keyboardUtil.hideKeyboardLayout();}else {return super.onKeyDown(keyCode, event);}return false;} elsereturn super.onKeyDown(keyCode, event);}private void initMoveKeyBoard() {keyboardUtil = new KeyboardUtil(this, rootView, scrollView);
// keyboardUtil.setOtherEdittext(normalEd);// monitor the KeyBarod statekeyboardUtil.setKeyBoardStateChangeListener(new KeyBoardStateListener());// monitor the finish or next KeykeyboardUtil.setInputOverListener(new inputOverListener());specialEd.setOnTouchListener(new KeyboardTouchListener(keyboardUtil, KeyboardUtil.INPUTTYPE_NUM, -1));}class KeyBoardStateListener implements KeyboardUtil.KeyBoardStateChangeListener {@Overridepublic void KeyBoardStateChange(int state, EditText editText) {
// System.out.println("state" + state);
// System.out.println("editText" + editText.getText().toString());}}class inputOverListener implements KeyboardUtil.InputFinishListener {@Overridepublic void inputHasOver(int onclickType, EditText editText) {
// System.out.println("onclickType" + onclickType);
// System.out.println("editText" + editText.getText().toString());}}