Android: Display custom keyboard then hide soft keyboard? - android

I have two EditText in my layout, and another layout that contains a custom designed keyboard using ImageButtons. Using these two layouts, I want to:
When the EditText is clicked/touched, hide the default keyboard.
Display the custom keyboard (like a replacement to the default keyboard).
Hide the keyboard after clicking back/return key.
I was able to hide the default keyboard by setting the InputType of the two EditText to NULL. However, it means that the cursor will no longer be visible when EditText is focused. This is part of the specifications of the project.
How do I best approach this problem? What could be a best solution?
Edit: Project specifications were changed. However, I would still love to have the solution or approach to this problem / issue. Thank you very much.

Related

Is there any way to provide animation for soft keyboard appearance in android?

Keyboard handling is still a major setback in Android app development. Let me be specific about my question, I want to provide animation for soft keyboard appearance. I know it is not feasible directly but do anyone know any workaround / tweaks & tricks for this?
you can try creating a custom soft keyboard and register your edittext to load this keyboard (take a look at the plethora of custom keyboards you can use https://android-arsenal.com/tag/232)
An example is "Floating KeyboardView" https://android-arsenal.com/details/1/5247 shows you how you can customise your keyboard.
Use it as normal keyboard view and
Place FloatingKeyboardView inside a FrameLayout or a RelativeLayout
(TIP: Put it last or/and with some elevation)
Make an xml with your keyboard layout
(https://developer.android.com/reference/android/inputmethodservice/Keyboard.html)
Declare it in activity code
FloatingKeyboardView mCustomKeyboard = (FloatingKeyboardView) findViewById(R.id.keyboardview);
Assign the keyboard layout
mCustomKeyboard.setKeyboard(new Keyboard(this, R.xml.numkbd));
Register edittexts to use it
mCustomKeyboard.registerEditText(R.id.edittext1);

Custom keyboard containing scrollview

I've been trying to create a custom android keyboard. I've started looking over "Creating an Input Method" guide from Google and I was able to create a regular keyboard using the Keyboard and KeyboardView elements.
The problem is that my keyboard needs a scrollview (or a recyclerview) so the user can scroll and see more items of the keyboard - but I don't think this can be achieved using the default Keyboard and KeyboardView elements.
I also tried to override the onCreateInputView method and add a custom layout that contained a scrollview - but the height of the keyboard was taking the entire screen and the user couldn't interact with the app anymore.
So if anyone has some ideas on how I can overcome this issues I would love to hear your suggestions.
Thanks

Resize layout with KeyboardView

I have a custom keyboard for my app only, and I have a KeyboardView in a layout. If I'm just using the built in keyboard, I can make the layout "shift" up and show the controls, edit texts, etc, above the keyboard.
Is this possible to do with a KeyboardView? Can I shift up the contents of my layout so the KeyboardView doesn't overlap any controls when it's showing?
EDIT
I guess some people with no experience in Android put the question on hold. If you understand Android, you understand the question, but in any case, here's an example.
Say I have a layout sort of like this:
<RelativeLayout>
<EditText />
</RelativeLayout>
If I'm just using the built-in soft keyboard I can set the adjustPan and/or adjustResize parameters in AndroidManifest.xml and when the soft keyboard shows up when I put focus on the EditText, the layout will shift up, so the edit text (and anything underneath for example) remain visible while the soft keyboard is showing.
But say I have:
<RelativeLayout>
<EditText />
<android.inputmethodservice.KeyboardView />
</RelativeLayout>
I create a custom keyboard xml file, and bind it to my KeyboardView, and show it when the edit text is focused. It is not an installable InputMethodService keyboard, but a specific keyboard for my activity only. Unfortunately the KeyboardView will now overlap the edit text, and any other controls. The adjustPan and/or adjustResize doesn't apply. So is there a simple, easy solution to getting the same behavior as the default soft keyboard, ie shifting the rest of the controls up when it becomes visible?
One person indicated I would probably have to do the shifting myself, and that seems likely. But I was hoping for a simpler solution, specific to the KeyboardView.
NOTE If you haven't used a KeyboardView before, then don't reply. This is specific to the KeyboardView. If you haven't used a KeyboardView, don't put a question on hold which specifically deals with that widget.

Android hide keyboard but a cursor stays on screen

Good morning!
On an app that I'm working on, I hide the soft keyboard and have a dark overlay appear on screen. The issue I'm having is that after the keyboard is hidden, there is still a little indicator/cursor on the EditText.
How can I hide this?
Many thanks!
You can use either the xml attribute android:cursorVisible or the java function setCursorVisible(boolean).

Removing navigation buttons from android soft keyboard?

I would like to remove the navigation buttons at the bottom of the soft keyboard ( the buttons with the arrow- they act like a tab key to move between fields). I have had no luck trying to find a way to do this. Does anyone have any suggestions
What you're describing is device-specific, as each device has its own default soft keyboard. Unfortunately, you'll need to make a custom keyboard.
Look at the Keyboard class.
I don't believe it's possible to remove the button from the keyboard, but you can at least specify which neighbor the field gives focus to. See Handling UI Events on the Android Dev Guide.
Perhaps it's possible to set nextFocusDown to nothing, so the keyboard doesn't let the user navigate in that fashion. If that doesn't work, you might consider setting the field that takes focus next to setFocusable(false).

Categories

Resources