长按Android自定义键盘弹出式键盘
我有定制的Android键盘:长按Android自定义键盘弹出式键盘,android,keyboard,android-softkeyboard,keyboard-events,android-input-method,Android,Keyboard,Android Softkeyboard,Keyboard Events,Android Input Method,我有定制的Android键盘: public class CustomKeyboard extends Keyboard{...} public class CustomKeyboardView extends KeyboardView{...} public class CustomKeyboardIME extends InputMethodService implements KeyboardView.OnKeyboardActionListener{...
public class CustomKeyboard extends Keyboard{...}
public class CustomKeyboardView extends KeyboardView{...}
public class CustomKeyboardIME extends InputMethodService implements KeyboardView.OnKeyboardActionListener{...}
在某些键上,我有popupKeyboard
和popupCharacters
:
<Key android:codes="144" android:keyLabel="0" android:popupKeyboard="@xml/key_popup" android:popupCharacters=")" android:keyEdgeFlags="right"/>
xml/key_popup.xml:
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="10%p"
android:horizontalGap="0px"
android:verticalGap="0px"
android:keyHeight="@dimen/key_height" >
</Keyboard>
但当我长按“0”键时,弹出框中会显示“)”,但在我按下“X”按钮或“)”字符之前,弹出框一直保持不变。看起来是这样的:我只想在我拿着手指的时候打开它。类似于三星或HTC键盘:
有人能帮我吗
编辑是否至少可以更改此弹出窗口的外观?我希望它具有与我制作的整个键盘相同的背景和按键/您可以使用
PopupWindow
类并使用自定义布局填充它
View custom = LayoutInflater.from(context)
.inflate(R.layout.your_layout, new FrameLayout(context));
PopupWindow popup = new PopupWindow(context);
popup.setContentView(custom);
长按
//Get x,y based on the touch position
//Get width, height based on your layout
if(popup.isShowing()){
popup.update(x, y, width, height);
} else {
popup.setWidth(width);
popup.setHeight(height);
popup.showAtLocation(yourKeyboardView, Gravity.NO_GRAVITY, x, y);
}
在弹出窗口中单击,您可以将其关闭
popup.dismiss();
有人能解决这个问题吗?我想如果你想定制键盘,你必须为所有东西定制视图。。。但是我不知道怎么做。这个链接可以帮助你,我想做一些类似的事情。您是如何解决问题的?我将使用以下方法: