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. ...
随机推荐
- Python 复习-1
#!/usr/bin/env python # -*- coding:utf-8 -*- # @Time : 2017/10/27 22:46 # @Author : lijunjiang # @Fi ...
- LeetCode OJ-- Binary Tree Maximum Path Sum ***
https://oj.leetcode.com/problems/binary-tree-maximum-path-sum/ 给一棵二叉树,路径可以从任一点起,到任一点结束,但是可以连成一个路径的.求 ...
- Codeforces Gym101522 A. Ambiguous Dates (La Salle-Pui Ching Programming Challenge 培正喇沙編程挑戰賽 2017)
A. Ambiguous Dates There are two popular formats for representing a date: day/month/year or month/da ...
- 洛谷——P1713 麦当劳叔叔的难题
P1713 麦当劳叔叔的难题 题目描述 话说我们铭铭小朋友成功的回答了爸爸的问题,自然少不了要去索要些奖励,抠门的爸爸一看报纸,嘿,门口的麦当劳在搞活动,还有免费午餐哦,不过前提条件:得正确回答麦当劳 ...
- P1243~P1247 线段树模板题总结
前言 这几天刚刚刷了5道线段树(水)题,现在来总结一下. 首先是犯的不少错误: 1.建树.更新函数没有return.这是最气的,每次最后程序错误查了半天也没查出来,最后发现是没有return.递归边界 ...
- html中常用的标签小结
内容详细标签: <h1>~<h6>标题标签<pre>格式化文本<u>下划线(underline)<i>斜体字(italics)<cit ...
- UVA 133“The Dole Queue”(循环报数处理技巧)
•参考资料 [1]:紫书P82 •题意(by紫书) 按照被选中的次序输出这 n 个人的编号: 如果A和B选中的是同一个人,输出一个这个人的编号: 输出格式:输出的每个编号占3个字节,不够3个字节在前面 ...
- js aop 拦载实现
var run = function(){ //is run } var aopBefore = function(){ //aopBefore } var tmpFn=run; run = func ...
- 【前端阅读】——《编程之魂》摘记&读后感&思维导图
前言:这本书全名叫<编程之魂——与27为编程语言创始人对话>,它的内容以采访对话为主,以图通过和顶级大师的真实交流来调查:大师们为什么要创建某种编程语言,它的技术如何开发.如何教授和学习, ...
- 《学习bash》笔记--调试shell程序
在shell中,最简单的调试助手时输出语句echo,能够通过把很多echo语句放到代码中进行调试,但必须花费足够的时间以定位 要查看的信息.可能必须通过很多的输出才干发现要查找的信息. 1.set选项 ...