Question

i just want to shift my whole activity screen upwards when the user clicks on the edit text... i mean the screen will shift upwards and below it we can see the soft keypad... I have tried using android:windowSoftInputMode="adjustPan|adjustResize" in my Manifest file but it doesn't make any sense.. thanks in advance ...

Was it helpful?

Solution

In your xml layout. Make the scrollview to be root parent, and it will work!

Try this to detect if keyboard is up, and then scroll down (you need your scroll to be root in xml):

final View activityRootView = findViewById(R.id.scroll);
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
    @Override
    public void onGlobalLayout() {
        int heightDiff = activityRootView.getRootView().getHeight() - activityRootView.getHeight();
        //keyboard is visible
        if (heightDiff > 100) {
            scroll.fullScroll(ScrollView.FOCUS_DOWN);
        }
    }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top