EditText遇到软键盘遮挡的坑

来源:互联网 发布:淘宝商品信息模板 编辑:程序博客网 时间:2024/05/17 06:15

EditText 遇到一个键盘遮挡巨坑: 我相信大家都会去清单文件设置什么
ativity属性

  android:windowSoftInputMode="adjustPan|stateAlwaysHidden"

然后我对应的布局如下

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:background="#eee"    android:orientation="vertical">    <EditText        android:layout_width="100dp"        android:inputType="textVisiblePassword"        android:gravity="right"        android:layout_height="wrap_content"        android:layout_alignParentBottom="true"        android:background="#f0f" /></RelativeLayout>

对应效果图
这里写图片描述

这时候我们运行程序,第一次点击文本边框确实布局会自动往上推然后显示编辑框。然后第二次点击的时候直接遮挡

这里写图片描述

原因:

android:inputType=""android:gravity="right"

两个属性连在一起出现导致的 —-这个问题我找了很久

解决:inputtype改为numeric 或者去掉gravity =“right”

0 0