I'm using this code that I got here to make a textview gone when a keyboard pops up. But when the keyboard is hidden I want the textview to be back again to its normal position. Also, when the textview is gone the edittext below it will go up. Then go back its normal position when the keyboard is hidden. How can I do that? Thanks!
final View activityRootView = findViewById(R.id.LinearLayout1);
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int heightDiff = activityRootView.getRootView().getHeight() - activityRootView.getHeight();
if (heightDiff > 100) // if more than 100 pixels, its probably a keyboard...
findViewById(R.id.titleTextView).setVisibility(View.GONE);
}
});