跳至主要内容

Android:如何设置底部控件view随着软键盘的弹出而上移

给EditText外加一个ScrollView,将高度设置统一,并给ScrollView设置属性

android:fillViewport="true"。





注:ScrollView只将EditView嵌套在其中即可,不可将其他组件放进来;不可随意在清单文件中给该activity设置软键盘属性。若弹出的软键盘遮挡了部分上移的view,可以在清单文件中给activity设置属性
android:windowSoftInputMode="adjustResize"


一些不必要的属性不要随意添加,以免影响实现功能效果。

4.部分主要代码示例:



[java] view plain copy
 print?
  1. <ScrollView  
  2.             android:layout_width="fill_parent"            
  3.             android:layout_height="44dp"  
  4.             android:fillViewport="true"  
  5.             android:scrollbars="vertical">  
  6.         <EditText  
  7.             android:id="@+id/et_password"  
  8.             android:layout_width="match_parent"  
  9.             android:layout_height="44dp"  
  10.             android:background="@drawable/edt_bg"  
  11.             android:drawableLeft="@drawable/key"  
  12.             android:drawablePadding="0dp"  
  13.             android:hint="输入交易密码"  
  14.             android:editable="true"  
  15.             android:password="true"  
  16.             android:cursorVisible="true"  
  17.             android:paddingLeft="5dp"  
  18.             android:singleLine="true" />  
  19.         </ScrollView>  

评论

此博客中的热门博文

javascript数组删除指定元素 remove index array specific

定义和用法 splice() 方法向/从数组中添加/删除项目,然后返回被删除的项目。 注释: 该方法会改变原始数组。 语法 arrayObject.splice(index,howmany,item1,.....,itemX) 参数 描述 index 必需。整数,规定添加/删除项目的位置,使用负数可从数组结尾处规定位置。 howmany 必需。要删除的项目数量。如果设置为 0,则不会删除项目。 item1, ..., itemX 可选。向数组添加的新项目。 返回值 类型 描述 Array 包含被删除项目的新数组,如果有的话。 说明 splice() 方法可删除从 index 处开始的零个或多个元素,并且用参数列表中声明的一个或多个值来替换那些被删除的元素。 如果从 arrayObject 中删除了元素,则返回的是含有被删除的元素的数组。

go url encoding

func  QueryUnescape func QueryUnescape (s string ) ( string , error ) QueryUnescape does the inverse transformation of QueryEscape, converting %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits. func  QueryUnescape func QueryUnescape (s string ) ( string , error ) QueryUnescape does the inverse transformation of QueryEscape, converting %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits.