Created
February 28, 2014 19:44
-
-
Save elqsar/9278343 to your computer and use it in GitHub Desktop.
Scroll to top in ScrollView if softkeyboard visible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onActivityCreated(Bundle savedInstanceState) { | |
super.onActivityCreated(savedInstanceState); | |
final View rootView = getActivity().getWindow().getDecorView().findViewById(android.R.id.content); | |
rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { | |
@Override | |
public void onGlobalLayout() { | |
int height = rootView.getRootView().getHeight() - rootView.getHeight(); | |
if(height > 100) { | |
loginScrollView.post(new Runnable() { | |
@Override | |
public void run() { | |
loginScrollView.smoothScrollTo(0, loginScrollView.getBottom()); | |
} | |
}); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment