I have seen a lot of posts to perform the contrary but here is what I want to achieve. After the user has performed a search through the SearchView, I would like it to stay open but without it being focused or the keyboard being visible.
If it is unclear, just have a look at how search behaves on the Play Store app.
I have tried to give focus to an other View on the screen, to call clearFocus() or setFocusable(false) on the SearchView but nothing works.
Any ideas ?
Thanks
OK. I finally nailed it.
Best way to do it is to override onStartActvityForResult and to manually close the keyboard. This way, you can handle yourself the search and nothing comes to disturb the SearchView which remains in the required state.
Related
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
I know this answer has been asked multiple times but there has not been a legit answer that solves this issue. To this day, I cannot believe Google has not added a listener for the SoftKeyBoard. I am curious to know if anyone has a solution to listening to the backPress while the keyboard is visible? I am asking this because within the Google play store when the search is visible and you press back, it hides the search and the keyboard at the same time. I have recreated the search but cannot find a legit answer to closing a custom searchview and the keyboard at the same time. I have tried a lot of answers but none of them are working.
I am calling "adjustPan" within the Manifest MainActivity to prevent custom views from being shifted. "adjustPan" prevents the root layout from making room for the softKeyboard, rather the softKeyboard is above the root layout. So this eliminates any measure solutions, which have been the main solution to most of the answers.
android:windowSoftInputMode="adjustPan"
Here is the custom SearchView
It is likely that Google is not listening for the onBackPressed event - but rather configuration changes that involve the keyboard. If you want to hide something when the keyboard changes to "hidden" then monitor the configuration with onConfigurationChanged and it will have the same effect.
See this post: How to capture the "virtual keyboard show/hide" event in Android?
I looked for the question everywhere on the Internet but can't find the answer. What I found is to hide the whole button tray all together.
When the keyboard is down, the button is shown as in the picture.
But when the keyboard is showing the icon changes to -
My problem is to change the button (as in the second image), when my emoticons are showing. So, is there any way by which I can programatically change the button on an event and change it back on another event?
I'm afraid this is not possible yet. Perhaps this will be implemented in later versions of Android.
Not all devices have an onscreen navigation bar, a lot of devices still have hardware buttons.
Nevertheless, you'll might find this article interesting: http://arpitonline.com/blog/2014/07/27/improving-androids-navigationbar/
Is there a way to keep the search (widget or dialog) open even if the user clicks on the screen? I've seen many Google apps doing this (Keep, GMail, Youtube...) but not so many apps from external developers...
I have my search edit text visible on the ActionBar but as soon as I tap somewhere else on the screen, it is dismissed. I only want it dismissed if the user clicks on the action bar icon or presses the back key.
Is it possible? Thanks in advance!
Intercept the touch event on the container view.
Check if the SearchView is expanded.
If it is do nothing
Other idea, is cutting the SearchView being collapsed whenever the container sends touch event signals down to the view tree if it is already expanded. Or make sure it does not collapse when the SearchView looses the focus. Make sure you properly collapsed, when back key is pressed.
These are just ideas.
Hope it helps.
I am trying to solve the issue that in my Webview, when a user selects a textfield, the keyboard that appears covers the text field below.
Instead, I need a behavior where the text field is moved right above the keyboard, like what the flag SOFT_INPUT_ADJUST_PAN would do.
Based on testing, it seems like by default on a Webview, it is displaying the keyboard below the field.
But my WebView is in fullscreen. I am calling this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN) in my activity);
and this seems to make android stop doing the default 'pan and scan' behavior.
I've tried to call
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
and even
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
but that did not fix it.
I need to set the activity to fullscreen because I want to hide both the title bar and the status bar, so removing it is not an option unless there is another way to hide the status bar.
Any idea on how to solve this issue?
Laurent
You need to remove FLAG_FULLSCREEN flag. There is a bug somewhere in the OS machinery and with some digging around i have found the following:
without any extra scroll view around web view adjustPan never worked for me. Unfortunatelly the add scroll view also not always helps.
adjustScroll works for me when FLAG_FULLSCREEN is not present for the activity the webview is in.
So to sum it up the safest option to go with when it comes to WebView is adjustResize not full screen activity.
For me this worked:
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);