平时开发中经常遇到的很小的问题,这里记录一下。
一般在AndroidManifest.xml中添加了android:windowSoftInputMode="adjustResize"或者adjustPan的话,页面中包含EditText控件进入时会自动弹出软件盘。

1.在包含EditText的父布局中添加android:focusable="true"android:focusableInTouchMode="true"

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"     android:focusable="true"     android:focusableInTouchMode="true"   >   <EditText       android:id="@+id/edit"       android:layout_width="match_parent"       android:layout_height="wrap_content"       android:inputType="text"       android:maxLines="1"       />LinearLayout>

这样可以禁止自动弹出软键盘

2.在AndroidManifest.xml中添加stateHidden,这样也不会自动弹出

".TestAActivity"     android:windowSoftInputMode="adjustResize|stateHidden">

3.进入页面强制隐藏软键盘

如果前两种方法都不起作用的话,可以使用这种方法:

/**  * 隐藏输入软键盘  * @param context  * @param view  */ public static void hideInputManager(Context context,View view){     InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);     if (view !=null && imm != null){         imm.hideSoftInputFromWindow(view.getWindowToken(), 0);  //强制隐藏     } }

更多相关文章

  1. android EditText 的键盘弹出(不弹出)坑爹
  2. Android平台上面输入法遮挡问题-android:windowSoftInputMode属
  3. Android横竖屏切换
  4. Android(安卓)搜索 把软键盘上的回车键改为搜索
  5. Android(安卓)studio添加httpclient的jar包
  6. Android禁止EditText自动弹出软键盘的方法及遇到问题
  7. Android(安卓)UI设计——ImageView和ImageButton控件
  8. This text field does not specify an inputType or a hint
  9. Android之ConstraintLayout(依赖约束)布局

随机推荐

  1. 关于Android的app权限申请问题
  2. Android(安卓)Camera2 之 CameraDevice
  3. mac电脑开发android找不到设备
  4. android 通过贝塞尔曲线 实现爱心点赞功
  5. Android(安卓)AppWidget(桌面小部件)
  6. android 背景平铺[转]
  7. Android(安卓)关机、重启、recovery流程
  8. 实现三星S3蒲公英水波纹效果(三)——Acti
  9. Android(安卓)Bundle传递对象
  10. android 读取资源字符串的 方法