I need custom Done button on keyboard in Android - android

Anyone help to add DONE button on top of soft keyboard like above screenshot shows.
Because I need Enter and Done both button on my Edit Text.
So, please suggest me If anyone have Idea.
Thanks in Advance...

How about just adding a custom Button in the bottom of your UI?
You can observe layout size changes -> find a case when keyboard appears and disappears (Remember its different case from screen rotation, different screen proportion)
Based on keyboard hidden/shown event you can show/hide your custom UI.
I guess only problem is, you don't know what is keyboard view background. But its definitely better than writting your own keyboard, AFAIK you can't add views to keyboards.

You have to create a custom keyboard for that. For custom keyboard you can try here:
https://code.tutsplus.com/tutorials/create-a-custom-keyboard-on-android--cms-22615
https://developer.android.com/guide/topics/text/creating-input-method.html
https://inducesmile.com/android/how-to-create-an-android-custom-keyboard-application/
http://www.blackcj.com/blog/2016/03/30/building-a-custom-android-keyboard/

You would like to have an easy solution? Then integrate your "Done" button in your layout. Your layout should look like this (short version):
<LinearLayout orientation="vertical">
<ScrollView layout_weight="1"> <-- if needed, use FrameLayout else
place your Layout here
</ScrollView>
<YourDoneButton/>
</LinearLayout>
Your Button will stack on the top of the keyboard. I assume, that the user should be able to click of the "Done" button even if the keyboard is hidden. If not, you can hide it if your EditText is not focused.

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);

Android | How to hide BottomNavigation even if windowSoftInputMode is set to 'adjustResize'?

I have an activity with BottomNavigation. If the user needs to click on the submit button soft keyboard hides it. Then he again needs to press the back button to see the submit button. In this case, I used windowSoftInputMode='adjustResize' so that the screen gets resized automatically and the user can scroll up and click on the submit button.
But, I have BottomNavigation too, windowSoftInputMode='adjustResize' makes BottomNavigation float above the soft keyboard. Can anyone suggest a better solution? Any help will be appreciated. Thanks
Thats tricky issue... You have two options in here:
Keep 'adjustResize' and hide BottomNavigation view when keyboard pops up (e.g. simply setVisiblity?)
Change to e.g. 'adjustPan' (or any other) preventing keyboard resizing app and add bottom padding with height of keyboard for whole content container. BottomNavigation will stay hidden under keyboard, but padding will allow scrolling to Submit button
In both cases you need to detect open/close keyboard, in second case you will also need keyboard height measuring. IN HERE and HERE you have big SO topics about this case, check out answers and comments, and pick proper resolution for your purposes

Hide view when showing keyboard

I have two EditText views and one ImageView. My goal is to hide the ImageView when i am showing the keyboard (When the user have clicked on one of the EditText fields)
Then show the imageView again when the user have unfocused the EditText field or the keyboard is not visible anymore.
I have tried tons of different ways to do this. But nothing really works as intended. Do you guys have any idea how i could achieve this
Have you tried to detect if the keyboard is opened ? How do I Detect if Software Keyboard is Visible on Android Device?
Make debug and when is opened try to hide image . imageview.setvisibility (GONE)
if it does not work you can try to change layout
Make 2 layouts and switch visibility if the keyboard is open /closed
You can add a OnFocusChangeListener to the EditText,when you click the EditText,it will get focus,and then you can hide the ImageView.
<activity android:name="SearchResultsActivity"
android:windowSoftInputMode="adjustPan"/>
adjustPan:
The activity’s main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.
regards! :)
You can do one thing, place UIView-> UIImageView -> UITextfield1-> UITextField2.Handle the UIImageView hiding state in textfield delegates which are Begin and End editing delegate methods

Show layout when soft keyboard opens

There is a CardView with an EditText and when the keyboard opens, it is placed right below the EditText. But as shown below, the keyboard is too close to the EditText and it is hard to press the "send" button because there is not enough space.
EditText:
EditText with focus:
Is there any way to show the keyboard after the end of the CardView?
I saw some similar questions here, but none of them provide a solution that I need. Some answers suggest to set a paddingBotton in EditText, but that is not what I want. I don't want space, I want to show the end of the CardView too.
Note that I don't want to resize the layout, so "adjustResize" is not the solution and I'm already using "adjustPan" in AndroidManifest.xml
<activity
...
android:windowSoftInputMode="adjustPan" />
Any thoughts?
If you are using scrollview. you can do one thing is to scroll your scrollview as your requirement
Please refer below code for example
ScrollView sv =(ScrollView)findViewById(R.id.scrl);
sv.scrollTo(0, sv.getBottom());
or
sv.fullScroll(View.FOCUS_DOWN);
this action you can perform on soft input of Enter key.
There is also one other solution you can hide the suggestion of keyboard by giving
android:inputType="textNoSuggestions"

Android Screen moves to edit text that has focus

in my activity I have multiple edit texts, and some animated sliders with buttons beneath them. The problem is when I open a slider and tap on the button, the screen "jumps" back up to the first edit text. How can I stop this from happening? I just want the screen to stay where it was after the button press. Any help will be appreciated.
EDIT/UPDATE I just played around with an iPhone. Would it rather be possible to remove focus from the edit text when the soft keyboard is minimized? (Removing the focus would work in regards to the original question of the screen navigating to the top by its self)
Add the following to your parent layout (i.e. LinearLayout, RelativeLayout, etc.)
android:focusableInTouchMode="true"
I used the following solution. I created a method:
public void clearFocusOnEditText(){
//editText.clearfocus()
}
I then added this method to my ontouch() and onClick() methods. I'm guessing this is not the best solution, but for all intents and purposes it works brilliantly.
add it in your manifest to the activity tag
android:windowSoftInputMode="stateHidden"

Categories

Resources