How can I get the height of virtual keyboard in Android? Is it possible?
I try to get it from the main window, but it gives me full height of the application. But I want to get the keyboard height.
How can I get the height of virtual keyboard in Android? Is it possible?
I try to get it from the main window, but it gives me full height of the application. But I want to get the keyboard height.
This solution is also hacky but solve the problem (atleast for me).
android:windowSoftInputMode="adjustResize"
flag in activity tag in manifest.Now main story is in
onGlobalLayout()
. There i calculate the difference between the y axis of temp view and height of root viewfinal View view = findViewById(R.id.base); view.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
});
Try this
If you don't want
android:windowSoftInputMode="adjustResize"
in your app. You can try something like this:you can use this sample code. it is dirty solution but it works
You can't get the keyboard height, but you can get the height of your View, which is what you really want - and you'll get this data supplied to the onLayout call into the current view.