当前Activity Edit获得焦点时,怎么设置不弹出键盘:

  android:windowSoftInputMode="stateHidden|adjustPan"
在Mainifest中对应的Activity设置这样的属性,这样软键盘就不会弹出来。

但是此时底部若有布局,会被软盘覆盖,这是为何呢?

"adjustPan":

The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.

这是官方的解释,从第一句我们就能看出此Activity并不会调整大小,由此可见,底部的bottom不会被顶上去。我们看看另外一个属性:

"adjustUnspecified":

It is unspecified whether the activity's main window resizes to make room for the soft keyboard, or whether the contents of the window pan to make the currentfocus visible on-screen. The system will automatically select one of these modes depending on whether the content of the window has any layout views that can scroll their contents. If there is such a view, the window will be resized, on the assumption that scrolling can make all of the window's contents visible within a smaller area.

This is the default setting for the behavior of the main window.

如果该窗口内有可以滑动的组件,那么这个窗口将会调整大小,而且这个属性是默认的,也就是说:

  android:windowSoftInputMode="stateHidden"
我这样设置属性和

 android:windowSoftInputMode="adjustUnspecified|stateHidden"
效果是一样的。我们写一个布局试一试:

<?xml version="1.0" encoding="utf-8"?>                                       
这里,用ScrollView包裹几个EditText 和ImageView,我们运行起来发现:

EditText android:windowSoftInputMode 属性之旅_第1张图片

OK,解决了。

更多相关文章

  1. Android七大布局
  2. android软键盘弹出引起的各种不适终极解决方案
  3. EditText所有属性详解
  4. ViewGroup之android:animateLayoutChanges属性

随机推荐

  1. Android(安卓)常用RGB值以及中英文名称
  2. Android菜鸟笔记-实现自动连接到指定的Wi
  3. android配置cmake
  4. eclipse下 Failed to find an AVD compat
  5. Android学习心得(24) --- Android(安卓)Han
  6. php7中停止php-fpm服务的方法详解
  7. PHP之Swoole学习安装教程
  8. 教你在react中创建自定义hooks
  9. js实现支付倒计时返回首页
  10. 通过vue方式实现二维码扫码功能