简体   繁体   English

Android键盘popupCharacters问题

[英]Android keyboard popupCharacters issues

I am developing a custom keyboard for android. 我正在为android开发一个自定义键盘。 I am trying to create a button when pressed smiley faces should popup. 当按下笑脸时,我正试图创建一个按钮。 It has come to my understanding that android:popupCharacters is responsible for displaying a popup on the keyboard as well as android:popupKeyboard. 据我所知,android:popupCharacters负责在键盘上显示弹出窗口以及android:popupKeyboard。 My problem is that for example if i put android:popupCharacters=":) :(" i get a popup with each character on a button by itself. How is it done? 我的问题是,例如,如果我把android:popupCharacters =“:) :(”我自己得到一个按钮上的每个字符的弹出窗口。它是如何完成的?

Thanks in advance 提前致谢

Read the doc carefully: http://developer.android.com/reference/android/inputmethodservice/Keyboard.Key.html#attr_android:popupCharacters 仔细阅读文档: http//developer.android.com/reference/android/inputmethodservice/Keyboard.Key.html#attr_android : popupCharacters

android:popupCharacters 机器人:popupCharacters

The characters to display in the popup keyboard . 在弹出键盘中显示的字符。

[...] [...]

android:popupKeyboard 机器人:popupKeyboard

The XML keyboard layout of any popup keyboard. 任何弹出键盘的XML键盘布局。

So popupcharacters means a simpler way to create popupkeyboard. 因此弹出字符表示创建弹出键盘的更简单方法。 But Unicode comes and saves you from creating XML and using images: http://unicodeemoticons.com/ Try them! 但是Unicode可以帮助您避免创建XML和使用图像: http//unicodeemoticons.com/试试吧! (Once I tried a long time ago, well displayed on 2.2 emulator, ZTE Blade and T-Mobile Pulse / Huwaei U8220). (很久以前我曾经尝试过,很好地展示在2.2模拟器,中兴Blade和T-Mobile Pulse / Huwaei U8220上)。

If you don't want this workaround, the other soulution is if you go into the android SDK source, and try to reimplement the whole popup keyboard (or over-implement, if you can) to make it available for you. 如果你不想要这个解决方法,另一个问题是如果你进入android SDK源代码,并尝试重新实现整个弹出键盘(或者过度实现,如果可以的话)让它可用。 But anyway, if I was the user, I would be more happy for the unicode or the images, but this is only my opinion. 但无论如何,如果我是用户,我会更喜欢unicode或图像,但这只是我的意见。

Create a separate xml layout for popups in xml directory as the following 为xml目录中的弹出窗口创建单独的xml布局,如下所示

<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
    android:keyWidth="15%p"
    android:horizontalGap="0px"
    android:verticalGap="0px"
    android:keyHeight="@dimen/key_height"
    >

<Row android:rowEdgeFlags="top">
        <Key android:keyLabel=":-)" android:keyOutputText=":-) "
        <Key android:keyLabel=":-)" android:keyOutputText=":-( "
    </Row>
</Keyboard>

Add as many row and/or key attributes as you like for additional smileys then use this in your keyboard xml 为其他表情添加任意数量的行和/或键属性,然后在键盘xml中使用它

    <Key android:keyOutputText=":-)" android:keylabel=":-)" android:popupKeyboard="@xml/popup"/>

This will create a key ":-)" which will output the character :-) if you press it once, and use the popup xml layout when you long press it. 这将创建一个键“:-)”,如果你按一下它将输出字符:-),并在你长按它时使用弹出式xml布局。

If you are making your own keyboard then check this following source code available which will help you a lot. 如果您正在制作自己的键盘,请查看以下可用的源代码,这将对您有所帮助。

Scandinavian-keyboard 斯堪的纳维亚键盘

Hackers Keyboard 黑客键盘

Android Emoji Keyboard Android表情符号键盘

Also you want to change theme of your keyboard then check following link .It will give you clear idea of how to make preview layout and all. 您还想更改键盘的主题,然后检查以下链接。它会让您清楚地了解如何进行预览布局等。 And specially if you want to check about smiley then Android Emoji Keyboard will be very useful. 特别是如果你想查看笑脸,那么Android表情符号键盘将非常有用。 It uses smiley symbols in keyboard and also in preview too. 它在键盘中使用笑脸符号,也在预览中使用。

Hope this will help you. 希望这会帮助你。

如果我已正确理解您的查询并且您想要实现类似于Watsapp-smiley-button的东西 ,那么您可以在按钮的onClick中使用PopupWindow并为其添加不同的表情符号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM