The default keyboard of android covers the EditText in my app UI. So i need to implement my on keyboard. Just like a keyboard in Regular Calculator app. Which is the best way to implement it? Is there any library available?
Custom keyboard
This link has everything required to create custom keyboard
In order to do not hide your edittext under the keyboard, you need to add the following line inside your Manifest file, under your activity section.
<activity
android:windowSoftInputMode="adjustPan"
...
...
Moreover, depending on your needs you can have the numeric keypad or the common keyboard shown. But this is more than what you asked.
Related
I have an app that, in a specific view uses a custom numeric keypad. The problem is the native keyboard keeps popping in the inputs on that view. How can I prevent that? I changed the inputs to read-only, and it seems to work, but without the cursor there is no way the user will know where he is editing. My app is initially an android-only app.
I need to use the native keyboard in other views, like the login view, as the password isn't numeric only.
Is there a way to prevent the native keyboard to open in a specific view? Or if I need to leave the readonly format, how can I "mask" the css to help the user?
I have a variable that is responsible for changing the ng-model attr value.
I thought of editing the css in the $watch of that variable, but how can I do that?
Thanks in advance!
This may help you.
Put this inside the Activities where you don't want the keyboard to be displayed.
<activity android:windowSoftInputMode="stateHidden" ...>
You can't prevent keyboard show as I know, but you can simulate the behaviour.
Use ionic keyboard plugin, and when the field is focused, just do cordova.plugins.Keyboard.close();
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.
I don't want to replace the entire soft keyboard. I want to add a Next/Prev buttons when the soft keyboard is deployed when a field in my WebView in the fashion that looks like the display on mylogin.yahoo.com
http://imgur.com/a/zH0Ux
I have found this on github
https://github.com/chrisboyle/sgtpuzzles/blob/master/src/name/boyle/chris/sgtpuzzles/SmallKeyboard.java
which seems like a reasonable way to accomplish this functionality.
Is extending android.inputmethodservice.KeyboardView be a reasonable way to go?
Mark
Yes, extend it is the best way to go. Wrap what you want to add. Create another keyboard and set it to that keyboard.
I have an activity with one EditText where I need to input numbers only.
Now, I have defined the Input Type for my EditText to be number only and have drawn up a pretty keypad for my user to use, however I also need to make sure the soft keyboard doesn't pop up for my user when they click on the EditText.
I have tried hiding the keyboard through the manifest by adding
android:windowSoftInputMode="stateAlwaysHidden"
in my Manifest for the particular activity, but this doesn't work for me because as soon as the user clicks on the EditText the keyboard appears again.
I've tried doing the same programmatically like so
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
but that doesn't work either. Keyboard appears when the user clicks on the EditText.
The only thing that worked was setting InputType to null for the EditText like so:
EditText.setInputType(InputType.TYPE_NULL);
but I cannot use this because it will allow users who have a keyboard attached to their device to input letters and other symbols in the EditText field, while I want everyone to specifically use only the keypad to enter data in the field.
I should also mention that I am currently testing my app under android 2.1, but I would like my solution to work across all versions. Any help would be appreciated. Thanks in advance.
Just thought it might be possible to extend EditText and handle the access to the softkeyboard through there and came across this question which has a very elegant solution to my problem.
Just followed the steps and this handled the softkeyboard perfectly for me. Hope it helps others that come across this issue.
In Whichever Edittext you need to disable the soft keyboard, add attribute in xml of that edit text.
<EditText android:id=".."
..
android:focusable="false" />
It will stop the execution of soft keyboard.
Use the android:windowSoftInputMode="stateHidden" in your activity in manifest file. This will work. Don't use the android:focusable="false" for EditText unless if you are not willing to input the text. If you want to give input then remove that property for the edittext in the layout file.
You can try this. It is working for me:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
If you are using for example ViewGroup it allows you to block the soft keyboard using this method:
view.setDescendantFocusability(view.FOCUS_BLOCK_DESCENDANTS);
Thanks to this the view will get focus before any of its descendants.
you can use This Code:
<EditText
.
.
android:enabled="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:inputType="numberPassword" />
Is there a way to programmatically remove certain keys from the standard software keyboard. By setting some of the input type flags I am so close to having the keyboard I need. From the calling application is there a way to modify the keyboard directly. I know how to make my own custom keyboard but it seems such a waste to remove one button from the standard one.
////// edit///////
I think I found a way around this if any one has tried this method please let me know if it worked for you.
I have going to grab the softKeyboard service and using the start hook the keyboard uses to grab its view object inflate my own and swap them.
From my research there is no way to implement your own custom keyboard from within a single application. If you want to have a custom keyboard you need to create one from scratch and can not use the IME
soft keyboard comes for edit text. you can modify the softkeyboard for that edit text.
For that you need to set inputType and imeOption property of that edit text.