Android 关于软键盘
一、.弹出的时候显示Editext框
添加布局replay_input
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/reply_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFF"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#80808080" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFF"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<EditText
android:id="@+id/reply"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:paddingRight="30dp" />
</RelativeLayout>
<Button
android:id="@+id/send_msg"
android:layout_width="50dip"
android:layout_height="35dp"
android:layout_margin="5dp"
android:background="@drawable/master_icon"
android:text="发送"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
2.编写代码
private PopupWindow editWindow;
View editView = mInflater.inflate(R.layout.replay_input, null);
editWindow = new PopupWindow(editView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
editWindow.setOutsideTouchable(true);
editWindow.setFocusable(true);
editWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
EditText replyEdit = (EditText) editView.findViewById(R.id.reply);
replyEdit.setFocusable(true);
replyEdit.requestFocus();
// 以下两句不能颠倒
editWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
editWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
editWindow.showAtLocation(rlPart, Gravity.BOTTOM, 0, 0);
// 显示键盘
final InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); editWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
if (imm.isActive())
imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
}
});
Android 关于软键盘的更多相关文章
- Android隐藏软键盘收回软键盘
代码改变世界 Android隐藏软键盘收回软键盘 InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPU ...
- android设置软键盘搜索键以及监听搜索键点击时发生两次事件的问题解决
在输入框中加入android:imeOptions="actionSearch",调用软键盘时,回车键就会显示搜索二字. 我想在点击搜索时,跳转到下一个页面,但是调用setOnKe ...
- android 表情,软键盘冲突解决方案(仿微博等SNS应用)
之前总想搞一下这个模块,可是由于忙碌总是推迟,现在就把这块好好的弥补过来,下面是我实现的思路.本人才疏学浅,还望大家不要见笑. 首先我们还是先看写示例: 上面应用应该不用我过多介 ...
- Android WebView 软键盘挡住输入框
解决方法一: 在所在的Activity中加入 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RES ...
- Android 禁止软键盘自动弹出
Android系统对EditText这个控件有监听功能,如果某个Activity中含有该控件,就会自动弹出软键盘让你输入,这个看似人性化的方案有 时候并不被用户喜欢的,所以在有些情况下要禁用该功能.这 ...
- Android隐藏软键盘
1,用java代码隐藏: /**隐藏软键盘**/ View view = getWindow().peekDecorView(); if (view != null) { ...
- Android中软键盘弹出时底部菜单上移问题
当在Android的layout设计里面如果输入框过多,则在输入弹出软键盘的时候,下面的输入框会有一部分被软件盘挡住,从而不能获取焦点输入. 解决办法: 方法一:在你的activity中的oncrea ...
- Android控制软键盘的弹出和隐藏
弹出软键盘 前提:必须要有一个可以编辑的控件(EditText),并且当前已经获取焦点 /** * 弹出软键盘 */ public void openKeyboard(View view) { // ...
- Android中软键盘展示、EditText焦点获取及windowSoftInputMode属性探究
2017-08-14 21:44:23 有很多中情况,分别展示. 1.Activity不做任何设置,布局使用LinearLayout 会自动滚动EditText之上的所有View,代码: <?x ...
- Android手动控制软键盘的开启和关闭,判断软键盘是否显示;
工具类,拿走就能用: import android.annotation.TargetApi; import android.app.Activity; import android.content. ...
随机推荐
- hexo添加百度统计
litten的主题yilia 编辑文件 themes/yilia/_config.yml,添加一行配置,可以删除原来的google analytics baidu_tongji: true 新建 th ...
- AC日记——[SCOI2007]蜥蜴 bzoj 1066
1066 思路: 网络流最大流: 拆点,每个点拆成两个,流量为这个点的高度: 注意,文中说的距离是曼哈顿距离(劳资以为开根号wa了不知道多少次): 每两个距离不大于d的点连边,流量inf: 如果距离能 ...
- codevs——2102 石子归并 2(区间DP)
时间限制: 10 s 空间限制: 256000 KB 题目等级 : 黄金 Gold 题解 查看运行结果 题目描述 Description 在一个园形操场的四周摆放N堆石子,现要将石子有次序地 ...
- 立即执行函数(IIFE)
立即执行函数(IIFE) 看到这里,相信你一定迫不及待地想知道究竟如何做了吧,其实很简单,只需要用括号全部括起来即可,比如下面这样: (function(){ /* code */ }()); 为什么 ...
- JAVA基础之集合、Iterator迭代器、泛型及增强for循环
个人理解: 对于集合,首先要明确的是最顶层的接口是Collection接口类,其包含一些基本的方法以便子类调用,不过在定义的时候最好定义好数据类型,以免遍历时还得必须进行向上转型:特别注意的是其没有关 ...
- UVA 11039 Building designing 贪心
题目链接:UVA - 11039 题意描述:建筑师设计房子有两条要求:第一,每一层楼的大小一定比此层楼以上的房子尺寸要大:第二,用蓝色和红色为建筑染色,每相邻的两层楼不能染同一种颜色.现在给出楼层数量 ...
- vs2013 x64 编译汇编代码
x64不再支持__asm, 只能单独放在一个.asm中. xxx.asm--------属性 应用 会出现 自定义生成工具. 下面黑体是我们修改的内容.
- Android 进度条对话框ProgressDialog
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- hdu254 DFS+BFS
这个题目需要注意以下几点: 1)注意界线问题,箱子和人不可以越界. 2)需要判断人是否可以到达人推箱子的指定位置. 3)不可以用箱子作为标记,因为箱子可以走原来走过的地方,我们用箱子和人推箱子的方向来 ...
- iscroll 子表左右滚动同时保持页面整体上下滚动
if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultExce ...