Is it possible to catch the event that Soft Keyboard was shown or hidden for EditText?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
I solved this issue by using onGlobalLayoutListener :
Here activityRootView is your Activity's root view.
try these methods:
showSoftInput(View, int, ResultReceiver)
andhideSoftInputFromWindow(IBinder, int, ResultReceiver)
. You can overrideonReceiveResult(int resultCode, Bundle resultData)
method ofResultReceiver
class to handle show/hide event.Hi I'd used following workaround:
As far as my content view is a subclass of LinearLayout (could be any other view or view group), I'd overridden onMeasure method lilke following:
This workaround helped me to hide some controls when keyboard is showing and bring back otherwise.
Hope this would be useful.
There actually isn't such an event to catch. The IME is simply showing and hiding its window; the feedback you get from this is the window manager causing your own window's content to resize if you have put it in resize mode.
In my case I wanted to hide a bottom bar when softkeyboard was shown. I considered best to just hide the bar when layout had less than a percent size of normal layout size. So I used this solution that works fine considering that soft keyboard usually takes 20% or more screen height. Just change the percent constant by any value you may think is ok. It needs attribute android:windowSoftInputMode="adjustResize" in manifest and layout must be the root to work.
Extend from any layout you may want instead of RelativeLayout.
Example:
layout/my_layout.xml
MyActivity.java
You can capture this by overwriting the
onConfigurationChanged
method of your activity: