Android开发之软键盘遮盖EditText
来源:互联网 发布:物品记录软件 编辑:程序博客网 时间:2024/05/21 11:09
写下此博客,是为了分享我遇到的使用多个EditText,软键盘弹出遮挡了输入框。
网上搜索了一大堆,基本都是说使用android:windowSoftInputMode="adjustPan" 就可以,但是此方法遇到按屏幕尺寸分比例的时候就行不通!
操作如下:
点击EditText,然后再点击屏幕空白处,软键盘隐藏,然后再点击同一个EditText,此时弹出的软键盘会遮盖出EditText。
下面说说我的解决方案:
第一步:
标红部分是必须的新增的,弹出软键盘时,整个窗体往上偏移,而不是使用android:windowSoftInputMode="adjustResize" 那样会压缩控件。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/rootview_register" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/c1_main" android:orientation="vertical" > <span style="background-color: rgb(255, 0, 0);"><ScrollView android:id="@+id/sv_register_all" android:layout_width="fill_parent" android:layout_height="fill_parent" ></span> <span style="background-color: rgb(255, 0, 0);"><LinearLayout android:id="@+id/ll_register_all" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" ></span> <RelativeLayout android:id="@+id/rl_register_top" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="3" >
第二步:
manifest中的Activity属性
<activity android:name="com.yjtc.msx.activity.RegistNewActivity" <span style="background-color: rgb(255, 0, 0);">android:configChanges="orientation|keyboardHidden"</span> android:screenOrientation="portrait" <span style="background-color: rgb(255, 0, 0);">android:windowSoftInputMode="adjustUnspecified"</span> />
第三步:
由于使用了ScrollView,那Activity中点击onTouch事件中的点击空白处隐藏软键盘,就会和Scrollview获取焦点冲突;此时必须监听Scrollview的OnTouchListener
sv_register_all.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (getCurrentFocus() != null && getCurrentFocus().getWindowToken() != null) { manager.hideSoftInputFromWindow(getCurrentFocus() .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } } return false; } });
到此,就完美解决遮盖问题了。
"——没有拼命的干劲,怎能有精彩的结果!"
版权声明:本文为博主原创文章,未经博主允许不得转载。若有错误地方,还望批评指正,不胜感激。
0 0
- Android开发之软键盘遮盖EditText
- EditText 软键盘遮盖
- Android EditText被软键盘遮盖处理
- Android EditText被软键盘遮盖
- Android EditText被软键盘遮盖处理
- Android EditText被软键盘遮盖处理
- Android EditText被软键盘遮盖的处理方法
- android 界面底部多行edittext框 弹出软键盘遮盖问题
- android避免弹出软键盘遮盖listview
- android避免弹出软键盘遮盖listview
- android避免弹出软键盘遮盖listview
- android避免弹出软键盘遮盖listview
- android避免弹出软键盘遮盖listview
- Android开发之软键盘在EditText上自动弹出之殇
- 软键盘遮盖
- Android手机软键盘遮盖输入框之重新布局详解
- Android手机软键盘遮盖输入框之重新布局详解
- Android手机软键盘遮盖输入框之重新布局详解
- mac电脑上将文件夹显示或者隐藏的命令
- hdu 4998 Rotate(计算几何)
- 不太常见的C函数
- iOS开源库
- WiFi基本知识
- Android开发之软键盘遮盖EditText
- oracle数据库表的解锁问题
- mybatis实战系列(三)mybatis中的分页使用 动态分页 物理分页
- 解决Win7&Win8 64位下Source Insight提示未完整安装的问题
- Developer--Services
- 字符串的转换
- hadoop 0.0.0.0/0.0.0.0:10020 connection refused
- android 应用性能提升
- TCP通信_客户端代码_C++