현재 내 클라이언트 요구 사항에 따라 사용자 지정 키보드 작업 중입니다. 한 가지 문제를 제외하고 모든 것은 저에게 잘 작동합니다. 제 문제를 단계별로 명확하게 설명하겠습니다.사용자 지정 키보드 겹침 EditText
- 하단에는 2 개의 EditText로 구성된 화면이 있습니다.
- Edittext를 클릭하면 KeyBoard가 정상적으로 작동하며 도 값을 입력 할 수 있습니다.
- 하지만 내 문제는 keyboard가 중복 된 Edittext이므로 이 필요합니다.
매니페스트에 일부 시나리오에서 해결할 경우<activity android:windowSoftInputMode="adjustPan|adjustResize"> </activity>
: EDITTEXT와
스크린 샷 :
키보드 글고 치기를 중복 617,451,515,
XML을 코드
<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:horizontalGap="0dp"
android:keyHeight="50dp"
android:keyTextSize="12sp"
android:keyWidth="25%p"
android:labelTextSize="12sp"
android:verticalGap="0dp" >
<Row>
<Key
android:codes="8"
android:keyEdgeFlags="left"
android:keyLabel="1" />
<Key
android:codes="9"
android:keyLabel="2" />
<Key
android:codes="10"
android:keyLabel="3" />
<Key
android:codes="69"
android:keyEdgeFlags="right"
android:keyLabel="-" />
</Row>
<Row>
<Key
android:codes="11"
android:keyEdgeFlags="left"
android:keyLabel="4" />
<Key
android:codes="12"
android:keyLabel="5" />
<Key
android:codes="13"
android:keyLabel="6" />
<Key
android:codes="56"
android:keyEdgeFlags="right"
android:keyLabel="." />
</Row>
<Row>
<Key
android:codes="14"
android:keyEdgeFlags="left"
android:keyLabel="7" />
<Key
android:codes="15"
android:keyLabel="8" />
<Key
android:codes="16"
android:keyLabel="9" />
<Key
android:codes="67"
android:iconPreview="@drawable/sym_keyboard_delete"
android:keyEdgeFlags="right"
android:keyIcon="@drawable/sym_keyboard_delete" />
</Row>
<Row>
<Key
android:codes="7"
android:keyLabel="0"
android:keyWidth="50%p" />
<Key
android:codes="66"
android:keyEdgeFlags="right"
android:keyLabel="Done"
android:keyWidth="50%p" />
</Row>
</Keyboard>
입니다 그리고 활동에 선언 할 때 내 자바 코드는
public class CustomKeyboardView extends KeyboardView {
public CustomKeyboardView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void showWithAnimation(Animation animation) {
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
setVisibility(View.VISIBLE);
}
});
setAnimation(animation);
}
public class BasicOnKeyboardActionListener implements OnKeyboardActionListener {
private Activity mTargetActivity;
/***
*
* @param targetActivity
* Activity a cui deve essere girato l'evento
* "pressione di un tasto sulla tastiera"
* @param mChangedListener
*/
public BasicOnKeyboardActionListener(Activity targetActivity) {
mTargetActivity = targetActivity;
}
@Override
public void swipeUp() {
// TODO Auto-generated method stub
}
@Override
public void swipeRight() {
// TODO Auto-generated method stub
}
@Override
public void swipeLeft() {
// TODO Auto-generated method stub
}
@Override
public void swipeDown() {
// TODO Auto-generated method stub
}
@Override
public void onText(CharSequence text) {
// TODO Auto-generated method stub
}
@Override
public void onRelease(int primaryCode) {
// TODO Auto-generated method stub
}
@Override
public void onPress(int primaryCode) {
// TODO Auto-generated method stub
}
@Override
public void onKey(int primaryCode, int[] keyCodes) {
long eventTime = System.currentTimeMillis();
KeyEvent event = new KeyEvent(eventTime, eventTime,
KeyEvent.ACTION_DOWN, primaryCode, 0, 0, 0, 0,
KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE);
mTargetActivity.dispatchKeyEvent(event);
}
입니다
private Keyboard mKeyboard;
public CustomKeyboardView mKeyboardView;
private void setCustomKeyBoard(){
mKeyboard = new Keyboard(mContext, R.layout.keyboard);
mKeyboardView = (CustomKeyboardView) findViewById(R.id.keyboard_view);
mKeyboardView.setPreviewEnabled(false);
mKeyboardView.setKeyboard(mKeyboard);
mKeyboardView.setOnKeyboardActionListener(new BasicOnKeyboardActionListener(this));
}
숨기기 및 키보드
/** Make the CustomKeyboard visible, and hide the system keyboard for view v. */
public void showCustomKeyboard(View v) {
mKeyboardView.setVisibility(View.VISIBLE);
mKeyboardView.setEnabled(true);
if(v!=null){
((InputMethodManager)mContext.getSystemService(Activity.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(v.getWindowToken(), 0);
}
}
/** Make the CustomKeyboard invisible. */
public void hideCustomKeyboard() {
mKeyboardView.setVisibility(View.GONE);
mKeyboardView.setEnabled(false);
}
I CLI를 나는 내 사용자 지정 IME 다음과 같은 코드를 추가와 비슷한 문제가 있었다