我已经成功地使我的部分布局消失了
activityRootView = findViewById(R.id.bottom_layout);
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int heightDiff = activityRootView.getRootView().getHeight() - activityRootView.getHeight();
System.out.println("Height: "+heightDiff);
if (heightDiff > 100) { // if more than 100 pixels, its probably a keyboard...
RelativeLayout bottom = (RelativeLayout)findViewById(R.id.bottom_layout);
bottom.setVisibility(View.GONE);
}else {
RelativeLayout bottom = (RelativeLayout)findViewById(R.id.bottom_layout);
bottom.setVisibility(View.VISIBLE);
}
}
});