Is there a way to tell if the soft-keyboard is shown?

According to this POST

You cannot detect if soft keyboard is shown or not, but you can indirectly know that a soft key board is shown by knowing that the View of your activity is resized.

Imagine you have a ListView and at the bottom an EditText, you want to go to the bottom of the list when a soft keyboard is shown after user clicks the EditText.

You need to implement a subclass of ListView, then use it in your ListActivity or Activity or View.

public class ThreadView extends ListView {

    public ThreadView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    @Override
    protected void onSizeChanged(int xNew, int yNew, int xOld, int yOld) {
        super.onSizeChanged(xNew, yNew, xOld, yOld);

        if (yOld > yNew) {
            setSelection(((ListAdapter) getAdapter()).getCount() - 1);
        }
    }
}

Hope this helps

PS. “check Configuration Changes” only works for hand keyboard.

Leave a Comment