当前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,我们运行起来发现:



OK,解决了。

更多相关文章

  1. Android分享界面制作(底部滑出动画)
  2. android:layout_weight的真实含义
  3. Android七大布局
  4. 一个不错的启动菜单显示屏动画效果
  5. Android(安卓)UI设计技巧
  6. Android属性系统
  7. android 4.4 设置默认日期格式
  8. listview使用小技巧
  9. Android(安卓)登录界面Demo源码

随机推荐

  1. 中科院和京东AI研究院提出:改进SRN人脸检
  2. 腾讯优图:开源YOLO系列代码(含YOLOv3以及各
  3. 你知道有哪些池化方法
  4. 如何解决树模型中one_hot的问题
  5. 德克萨斯大学提出:One-stage目标检测最强
  6. 如何用自己的数据制作Pascal VOC格式数据
  7. 在 React 中缩放、裁剪和缩放图像
  8. JavaScript 中的代理对象
  9. 我16年考研
  10. 亚马逊提出:用于人群计数的尺度感知注意力