【问题标题】:Is it possible to bring the android keyboaord to the bottom of the screen是否可以将android键盘带到屏幕底部
【发布时间】:2019-04-09 21:38:39
【问题描述】:

是否可以将android键盘带到屏幕底部而不是停留在屏幕底部,

由于当键盘出现在 android 布局的底部时我的按钮不可见,我不希望按钮位于顶部,但我希望键盘出现在屏幕顶部。

【问题讨论】:

标签: android android-layout


【解决方案1】:

将它放在清单文件中,将调整您的视图并使用户交互变得容易

 <activity
    android:name="com.example.myactivity"
    android:windowSoftInputMode="adjustResize" />

【讨论】:

  • 不,这对我没有帮助。我希望键盘显示在顶部而不是显示在屏幕底部
【解决方案2】:

试试这个,软键盘弹出时底部布局会隐藏

 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);
            }
        });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-02-02
    • 1970-01-01
    • 2011-03-04
    • 2020-11-22
    • 1970-01-01
    • 2017-09-13
    • 1970-01-01
    相关资源
    最近更新 更多