解决位于底端Edittext 输入时被软盘遮盖详解手机开发
2023-06-13 09:20:15 时间
遇到这种情况我们首先到网上搜一圈,大概情况是需要设置 activity/
另还需注意,具体问题具体分析。
android:windowSoftInputMode= adjustResize ,按照以上属性设置了,问题依然存在没有解决。
通过反复试验,得出结论布局文件的layout_weight权重为影响软盘覆盖edittext。成功的xml文件如下:?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:background="#f4f6f5" android:orientation="vertical" !-- head bar -- include layout="@layout/include_head_bar" / ListView android:id="@+id/listview" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_weight="1" android:layout_marginLeft="10.0dip" android:layout_marginRight="10.0dip" android:layout_marginTop="10.0dip" android:cacheColorHint="#00000000" android:divider="@null" android:dividerHeight="5dp" android:scrollbars="none" / LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="5" RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="5dp" LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="#f5f5f5" ImageButton android:id="@+id/btnVoice" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#00000000" android:paddingLeft="5dp" android:src="@drawable/voice" / EditText android:id="@+id/txtContent" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left" android:layout_marginLeft="5dp" android:layout_weight="1" android:background="@drawable/shape_consult_search" android:completionThreshold="1" android:hint="输入内容" android:paddingLeft="8dp" android:textColor="#000000" android:textColorHint="#c2c2c2" android:textCursorDrawable="@null" / ImageButton android:id="@+id/btnPic" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:background="#00000000" android:src="@drawable/pic" / Button android:id="@+id/btnConsult" android:layout_width="wrap_content" android:layout_height="40dp" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:background="@drawable/shape_consult_top_btn_press" android:text="发送" android:textColor="#ffffff" / /LinearLayout /RelativeLayout /LinearLayout /LinearLayout
效果图:
?xml version="1.0" encoding="utf-8"? LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="match_parent" android:background="#e9e9e9" android:focusable="true" android:focusableInTouchMode="true" android:orientation="vertical" LinearLayout android:layout_width="match_parent" android:layout_height="50dp" android:background="#f0f0f0" android:gravity="center_vertical" TextView android:id="@+id/return_back" android:layout_width="wrap_content" android:layout_height="match_parent" android:drawableLeft="@drawable/return_back" android:gravity="center|center_vertical" android:paddingLeft="15dp" android:text="@string/return_back" android:textColor="#20bf63" android:textSize="22sp" / TextView android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="2" android:gravity="center|center_vertical" android:text="@string/zx_tit" android:textColor="#000000" android:textSize="22sp" / TextView android:layout_width="40dp" android:layout_height="match_parent" android:gravity="center_vertical" android:singleLine="true" / /LinearLayout LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#ffffff" android:orientation="vertical" android:paddingBottom="15dp" android:paddingLeft="15dp" android:paddingRight="15dp" android:paddingTop="10dp" LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" TextView android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignParentLeft="true" android:layout_gravity="left" android:layout_weight="1" android:text="@string/zx_name" android:textColor="#8b8b8b" android:textSize="18sp" / TextView android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignParentRight="true" android:layout_gravity="right" android:layout_weight="1" android:gravity="right" android:text="@string/zx_time" android:textColor="#8b8b8b" android:textSize="18sp" / /LinearLayout TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" android:text="@string/zx_text" android:textColor="#000000" android:textSize="18sp" / /LinearLayout LinearLayout android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_weight="1" RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" ListView android:id="@+id/listview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="10.0dip" android:layout_marginRight="10.0dip" android:layout_marginTop="10.0dip" android:cacheColorHint="#00000000" android:divider="@null" android:dividerHeight="5dp" / LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="#f5f5f5" EditText android:id="@+id/txtContent" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left" android:layout_marginLeft="5dp" android:layout_weight="1" android:background="@drawable/shape_consult_search" android:completionThreshold="1" android:hint="输入内容" android:paddingLeft="8dp" android:textColor="#000000" android:textColorHint="#c2c2c2" android:textCursorDrawable="@null" / Button android:id="@+id/btnConsult" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:background="@drawable/shape_consult_top_btn_press" android:text="发送" android:textColor="#ffffff" / /LinearLayout /RelativeLayout /LinearLayout /LinearLayout
我们首先分析下这个布局文件:由三个linearlayout组成,其中前两个layout的高度肯定可以确定其高度,第三个layout比较复杂,包含一个 listView relativelayout ,listview
中的内容是动态的,也就是说高度不定,内容不定;而且还有下边[发送]必须在屏幕的底端显示;假如我们把listview提到独立的layout中,当我们点击edittext输入内容时,就会被 软盘挡住。![解决位于底端Edittext 输入时被软盘遮盖详解手机开发](http://blog.ytso.com/zb_users/plugin/LazyLoad/usr/loading.gif)
6160.html
app程序应用开发手机开发无线开发移动端开发相关文章
- c语言scanf函数用法详解_c语言输入scanf格式
- 2022-09-09:给定一个正整数 n,返回 连续正整数满足所有数字之和为 n 的组数 。 示例 1:输入: n = 5输出:
- QQ对话框提示“当前网页非官方页面,请勿输入QQ帐号和密码,如需访问,请复制后使用浏览器访问”怎么办?
- iOS判断输入中字符串长度的代码详解手机开发
- Linux终端输入之谜:无法再操作(linux终端无法输入)
- Linux QQ输入法,为你打造高效输入体验(linuxqq输入法)
- Linux系统下如何实现输入中文 详细步骤(linux系统输入中文)
- 输入Linux环境下如何实现中文输入(linux环境中文)
- MySQL主键输入方法介绍(mysql 中主键怎么输)
- 在CMD中简单访问MySQL(cmd中输入MySQL)
- javascript输入CD-KEY自动分割的代码
- 检查输入的是否是数字使用keyCode配合onkeypress事件