Hi i am working on android soft keyboard. Normally labels displayed on
keys are single character as shown below
the above one is done by just using keylabel attribute of Key tag in Keyboard
to display whatever text we want on the key. But now my requirement is to display multiple characters on single key as shown below
I got one solution to this by using android:keyIcon but limitation is I need the color of characters to be configurable so that a user can change color of any character. Like 1 with red, | with blue, q with green. So it must be configurable to any color.That's why I skipped keyIcon property for displaying text on character.
So is there any way to set multiple characters on key.
The standard KeyboardView provided by android framework doesn't support displaying secondary text (or multiple characters). To achieve your desired functionality you need to subclass the KeyboardView(or simply View) and implement its onDraw method and draw directly to the Canvas.
You can check the source code of latinIME KeyboardView where its been implemented using hint label.
Also you need to write your own parser for parsing the Keyboard xml. you can check here how its done in LatinIME.
Understanding the complete package Keyboard in LatinIME will be very helpful for your requirement.
Hi I have done it with by taking reference of Customize the appearance of a <Key>
By playing with given code after three days i have got my solution.
Related
What I need is to stop edittext from Rendering system default Emojis
and use my own emojis with the same rendering way ( unicodes ) , so I DONT to FILTER the Text so it wont pass the text between a range so that emojis wont show up and I just don't know which method to override or remove from default EditText to stop this rendering . the casue I need to do this is that whenever I want to render my own emojis it will first be rendered to system default emojis and quickly changes the span to mine and this isn't nice
if I use filters then I wont be able to enter any emojis with Unicode so filtering by emoji Unicode range is not the ANSWER !
in EditText xlm set attribute
app:emojiCompatEnabled="false"
it will stop render emoji by AppCompat
To display the emoji button in the soft keyboard I use this in the EditText:
android:inputType="textShortMessage"
which uses the emoji icons for my device (which may be specific to my carrier/phone model).
I want to use my own set of drawables instead. Is there a way to do this without having to create a completely new soft keyboard?
No, there isn't any single line solution, maybe there is one at Lollipop as it is shipped with emoticons.
Options:
Implement a keyboard (needs a lot of effort + user to change his default keyboard)
Implement a panel/dialog that act as keyboard (needs less effort)
Use an existing library to do so a list of libraries is here but you can search for more if you want!
I was able to solve this by using the EmojiHandler from here:
To get the unicode of the emoji from textual message content:
String s = EmojiHandler.decodeJava(content);
// use decoded string to display emoji in TextView, Button, etc
textButton.setText(s);
To encode the emoji from the softkeyboard and put it into a String:
String encodedEmoji = EmojiHandler.encodeJava(msgText);
Is there any way to input special characters (which are not present in the default soft keyboard ,eg. theta) in an Android EditText?
Thanks..
Well as per your need, I would like to suggest to create a custom keyboard because the stock keyboard which comes with the device may not have the special characters you need.
You can refer the following tutorial to create a custom keyboard
http://www.fampennings.nl/maarten/android/09keyboard/index.htm
or you can see this search result which may serve your purpose,
https://github.com/search?q=android+custom+keyboard&ref=cmdform
And from below site you can get the list of Unicode characters which Android supports,
http://en.wikipedia.org/wiki/List_of_Unicode_characters
http://unicode-table.com/en/#0026
Note: Writing the whole code to create a custom keyboard is beyond the scope of this answer, so I mentioned the reference link.
What you are going to do is to create a custom keyboard. First thing you want is to hide the default keyboard when an EditText is focused:
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Now, you must create a custom layout (RelativeLayout or Multiple LinearLayouts this is your desire), create and set text to the buttons that you want to show. Make this keyboard view setVisibility(View.INVISIBLE) or setVisibility(View.GONE), and whenever your EditText is focused, make it setVisibility(View.VISIBLE).
After keyboard is visible, programming the rest is up to you it is practically easy.
If you also need a guide, here is an example.
The input type for my EditText control is set to "number." When the numeric keypad is displayed, besides showing the numbers, it also shows calculator keys (+/-/etc.). I am wondering if there is any setting to remove the calculator keys.
Thank you in advance for your help.
If all you need are actual numbers 0-9 you could set your keyboard type to "phone" instead of "number" which should give you a more 9-pad style keyboard that probably won't contain the extra keys like +, - etc...
However in the end it is up the currently running keyboard application (which is chosen by the user) If whatever keyboard they happen to be using shows keys that you would rather it not, there is generally no way for you to instruct it not to show those keys.
If you want to have complete control over the input then you'll have to create your own View that mimics the functionality of the keyboard and "manually" insert the typed characters into your EditText.
Add this line of code
input.setInputType(InputType.TYPE_CLASS_NUMBER);
Hope it helps.
I am creating a custom keyboard using KeyboardView class provided in API. I want to change the typeface of the label of keys. (i.e. using kiran.ttf file, 'K' will then Displayed as 'क')
I have searched a lot, but couldn't succeeded yet.
Thanks in advance.
The only real way to do this (and have it output the correct symbol to an EditText when using the keyboard) is to use UTF-8 unicodes. I'm currently developing an engineering keyboard, and I simply found all the symbols I needed, then I output the unicode using getCurrentInputConnection().commitText("\u2220", 1);
In your case, if you were looking for that character you've got in the question, it's unicode is \u0915
Adding that to my keyboard (for demonstration purposes) gives me this:
with the output in the editText near the top of the screen. The key itself is in the top left corner of the keyboard. The specific set of unicode that comes from is called "Devanagari", and the characters can be found here: http://unicode.org/charts/PDF/U0900.pdf.
Hope that helps!