我正在研究改变Android的输入方法的各个部分,特别是输入坐标.
所需的键/字符是1234567890.-:当选择数字签名和十进制时,我有前12个覆盖,但不能得到:被包括或任何其他可以取代它的角色(完美的是有一把°钥匙).
我现在用输入过滤器编写过滤这些字符:它可以工作,但它不漂亮.我的主要问题是我不能让键盘在数字侧而不是字母侧打开.
我非常感兴趣的另一个选择是修改现有的电话类型键盘以包括我想要的键.它会消除很多混乱并使剩余的键变大,从而使输入更容易.
我无法弄清楚如何使用Android发送元键(例如CTRL)和键码(例如用于RETURN)的组合(我使用API级别11 =版本3.0).
KeyEvent类的文档提到了诸如META_CTRL_ON之类的常量,并且还支持元键的键码常量(例如KEYCODE_CTRL_LEFT).
我正在使用Javascript Key Event Tester测试输入法编辑器(IME)生成的输出.顺便说一句,我的目标是开发一个软件键盘.
如果我理解正确的文件,这将足以执行以下代码发送CTRL键唯一:
this.sendDownUpKeyEvents(KeyEvent.KEYCODE_CTRL_RIGHT);
Run Code Online (Sandbox Code Playgroud)
但是当针对Javascript Key Event Tester(见上文)执行此操作时,没有任何反应.
因此,我需要了解如何仅发送元密钥以及将元密钥与另一个密钥组合发送.我也尝试了以下发送SHIFT + ENTER(一个具体的例子):
private void _sendShiftEnter() {
this.sendDownKeyEvent(KeyEvent.KEYCODE_SHIFT_LEFT);
final long eventTime = SystemClock.uptimeMillis();
this.getCurrentInputConnection().sendKeyEvent(
new KeyEvent(
eventTime, // The time (in uptimeMillis()) at which this key code originally went down.
eventTime, // The time (in uptimeMillis()) at which this event happened.
KeyEvent.ACTION_DOWN, // Action code: either ACTION_DOWN, ACTION_UP, or ACTION_MULTIPLE.
KeyEvent.KEYCODE_ENTER, // The key code.
0, …Run Code Online (Sandbox Code Playgroud) 我实现了一个名为RemoteInput的输入方法,只是扩展InputMethodService,没有InputViews而没有键盘.当用户选择RemoteInput作为默认IME时,RemoteInput会将当前输入状态发送给其他设备,用户可以远程执行输入操作(使用我们的定制协议).输入完成后,在其他设备中输入的文本将被发送回当前设备,然后RemoteInput将文本提交到当前UI组件(如EditText)上InputConnection.commitText (CharSequence text, int newCursorPosition).
当远程输入的文本是英文字符和数字时,它是完美的,但是当涉及到其他字符时出现问题.我发现InputConnection.commitText过滤其他字符.例如,我输入hello??,只能hello成功提交.和更多:
hello world ==> helloworldhello,world!! ==> helloworld你提出的任何事情都会有所帮助,在此先感谢你们.
这是我的代码:
public class RemoteInput extends InputMethodService {
protected static String TAG = "RemoteInput";
public static final String ACTION_INPUT_REQUEST = "com.aidufei.remoteInput.inputRequest";
public static final String ACTION_INPUT_DONE = "com.aidufei.remoteInput.inputDone";
private BroadcastReceiver mInputReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (ACTION_INPUT_DONE.equals(intent.getAction())) {
String text = intent.getStringExtra("text");
Log.d(TAG, "broadcast ACTION_INPUT_DONE, …Run Code Online (Sandbox Code Playgroud) 我有一个带有单个EditText的片段,需要软键盘不断打开.旋转屏幕时键盘会隐藏.我在OnActivityCreated中调用showSoftInput,它在旋转后执行,但它不显示键盘.
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(edit, 0);
Run Code Online (Sandbox Code Playgroud)
注意:我不想使用toggleSoftInput.我试过了,但在某些情况下最终会关闭键盘.并且无法查询android以确定键盘是否已打开.
android android-keypad android-softkeyboard android-input-method
您可以设置TextView的inputType,从值的一个InputType暗示,在键入的文字应该是一个人的名字,电话号码,&C.即使输入方法不遵守此提示,也TextView使用a KeyListener和/或TransformationMethod确保只能输入相关字符,或者具有屏蔽密码等效果.即使是标志也不只是提示:它们可以改变TextView显着的行为(最明显的例子EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE).
谷歌的文档对每个文件的实际效果都非常模糊inputType.每种情况下实际允许哪些字符?如果有的话,这会因地区而异?即使没有记录的答案,并且它可能在版本之间发生变化,我仍然想知道预期的行为.
我正在尝试实现一个键盘应用程序,它应该能够将图像发送到当前活动(Whatsapp,消息应用程序等).
有没有办法真正实现这一目标?当然它仅限于接受图像的应用程序,但我想知道什么是最好的方法.
尝试使用带有ImageSpan的StringBuilder但无法使其工作.我想知道是否有更好的方法.使用Intents可能吗?
android android-intent android-softkeyboard android-input-method
...就像这张图片中的 "Swype设置" .一直在寻找如何做到这一点的几个小时.要疯了.帮助赞赏.
如何在android InputMethodService中添加自定义图像作为表情符号.我试过用
ImageGetter imageGetter = new ImageGetter() {
public Drawable getDrawable(String source) {
StringTokenizer st = new StringTokenizer(str, ".");
Drawable d = new BitmapDrawable(getResources(),emoticons[Integer.parseInt(st.nextToken()) - 1]);
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
return d;
}
};
Spanned cs = Html.fromHtml("<img src ='"+ str +"'/>", imageGetter, null);
getCurrentInputConnection().commitText(cs,1);
Run Code Online (Sandbox Code Playgroud)
但只是得到
一个obj文本图像.有没有办法在android中添加自定义表情符号到消息(whatsapp/twitter)
编辑:
在我的应用程序中如果我使用我的自定义键盘键入你好我必须在编辑字段中为手机中安装的每个应用程序插入一个自定义的hello图片.
能实现吗?
编辑:2
我已经使用转换法师检查了它到base64,但Tag没有任何反应
ImageGetter imageGetter = new ImageGetter() {
@Override
public Drawable getDrawable(String source) {
byte [] encodeByte=Base64.decode("iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",Base64.DEFAULT);
Bitmap bitmap=BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length);
Drawable d = new BitmapDrawable(bitmap);
Log.e("Chk", "Height : "+d.getIntrinsicHeight()); …Run Code Online (Sandbox Code Playgroud) 我是android的新手并且正在进行警报对话框的演示,我想在点击警报中的一个按钮后关闭软键盘.我已经尝试了programaticaly但键盘仍然打开,你能不能帮我这个问题, 代码
public void Show_Dialog() {
final AlertDialog.Builder alertDialog = new AlertDialog.Builder(
SwipeActivity.this);
LayoutInflater inflater = this.getLayoutInflater();
final View layout = inflater.inflate(R.layout.add_albom_dialog, null);
alertDialog.setView(layout);
final InputMethodManager inputManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
//android:digits="abcdefghijklmnopqrstuvwxyz1234567890 "
alertDialog.setPositiveButton("Create",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
EditText txts = (EditText) layout
.findViewById(R.id.addAblum_edit);
hideSoftKeyboardDialogDismiss(SwipeActivity.this);
if(txts.getText().toString().trim().length() > 0) {
Add_album(txts.getText().toString());
} else {
AlertDialog alertDialog = new AlertDialog.Builder(SwipeActivity.this).create();
alertDialog.setTitle("Error");
alertDialog.setMessage("Name can't be emtpy");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss(); …Run Code Online (Sandbox Code Playgroud) android android-softkeyboard android-input-method android-alertdialog
我想在键盘(Android IME)中创建一个像 Gboard 这样的搜索栏,如图所示。
Gboard 示例:

我已经在 Keyboardview.xml 上实现了一个编辑文本,如图所示。
我的实现:

main_keyboard_frame.xml
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="120dp"
android:background="#cf060610"
android:id="@+id/search_panel"
android:visibility="invisible">
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:hint="sdsddsd"
android:id="@+id/ed"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
但问题是当我按下edittext 2(在我的ime之外)然后我的ime打开,其中包含edittext 1,如上图所示,现在当我从我的ime中写一些东西时,它写在edittext 2而不是edittext 1上,所以我想知道这背后的问题是什么?有重点吗?或者是其他东西?
java android android-input-method custom-keyboard android-custom-keyboard