【发布时间】:2019-04-09 21:38:39
【问题描述】:
是否可以将android键盘带到屏幕底部而不是停留在屏幕底部,
由于当键盘出现在 android 布局的底部时我的按钮不可见,我不希望按钮位于顶部,但我希望键盘出现在屏幕顶部。
【问题讨论】:
-
stackoverflow.com/questions/55531811/… 在这里查看我的答案
是否可以将android键盘带到屏幕底部而不是停留在屏幕底部,
由于当键盘出现在 android 布局的底部时我的按钮不可见,我不希望按钮位于顶部,但我希望键盘出现在屏幕顶部。
【问题讨论】:
将它放在清单文件中,将调整您的视图并使用户交互变得容易
<activity
android:name="com.example.myactivity"
android:windowSoftInputMode="adjustResize" />
【讨论】:
试试这个,软键盘弹出时底部布局会隐藏
rootLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int heightDiff = rootLayout.getRootView().getHeight() - rootLayout.getHeight();
if (heightDiff > Utilities.convertDpToPixel(200, ReportDetailsActivity.this)) { // if more than 200 dp, it's probably a keyboard...
// ... do something here
ll_bottom_navigation.setVisibility(View.GONE);
} else ll_bottom_navigation.setVisibility(View.VISIBLE);
}
});
【讨论】: