一、.弹出的时候显示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 关于软键盘的更多相关文章

  1. Android隐藏软键盘收回软键盘

    代码改变世界 Android隐藏软键盘收回软键盘 InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPU ...

  2. android设置软键盘搜索键以及监听搜索键点击时发生两次事件的问题解决

    在输入框中加入android:imeOptions="actionSearch",调用软键盘时,回车键就会显示搜索二字. 我想在点击搜索时,跳转到下一个页面,但是调用setOnKe ...

  3. android 表情,软键盘冲突解决方案(仿微博等SNS应用)

    之前总想搞一下这个模块,可是由于忙碌总是推迟,现在就把这块好好的弥补过来,下面是我实现的思路.本人才疏学浅,还望大家不要见笑. 首先我们还是先看写示例:            上面应用应该不用我过多介 ...

  4. Android WebView 软键盘挡住输入框

    解决方法一: 在所在的Activity中加入 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RES ...

  5. Android 禁止软键盘自动弹出

    Android系统对EditText这个控件有监听功能,如果某个Activity中含有该控件,就会自动弹出软键盘让你输入,这个看似人性化的方案有 时候并不被用户喜欢的,所以在有些情况下要禁用该功能.这 ...

  6. Android隐藏软键盘

    1,用java代码隐藏: /**隐藏软键盘**/        View view = getWindow().peekDecorView();        if (view != null) { ...

  7. Android中软键盘弹出时底部菜单上移问题

    当在Android的layout设计里面如果输入框过多,则在输入弹出软键盘的时候,下面的输入框会有一部分被软件盘挡住,从而不能获取焦点输入. 解决办法: 方法一:在你的activity中的oncrea ...

  8. Android控制软键盘的弹出和隐藏

    弹出软键盘 前提:必须要有一个可以编辑的控件(EditText),并且当前已经获取焦点 /** * 弹出软键盘 */ public void openKeyboard(View view) { // ...

  9. Android中软键盘展示、EditText焦点获取及windowSoftInputMode属性探究

    2017-08-14 21:44:23 有很多中情况,分别展示. 1.Activity不做任何设置,布局使用LinearLayout 会自动滚动EditText之上的所有View,代码: <?x ...

  10. Android手动控制软键盘的开启和关闭,判断软键盘是否显示;

    工具类,拿走就能用: import android.annotation.TargetApi; import android.app.Activity; import android.content. ...

随机推荐

  1. 线程之间通信 等待(wait)和通知(notify)

    线程通信概念: 线程是操作系统中独立的个体,但这些个体如果不经过特殊的处理就不能成为一个整体,线程之间的通信就成为整体的必用方式之一.当线程存在通信指挥,系统间的交互性会更强大,在提高CPU利用率的同 ...

  2. 用Gson解析没有数据头的纯数组json字符串

    无数据头Json字符串 Json字符串只有数组,而次数组没有名字,如下 [ { "name": "zhangsan", "age": &qu ...

  3. Jsp2.0自定义标签(第二天)——自定义循环标签

    今天是学习自定义标签的第二天,主要是写一个自定义的循环标签. 先看效果图: 前台页面Jsp代码 <%@ page language="java" contentType=&q ...

  4. 卸载django

    首先找到django安装路径 Python import sys; sys.path = sys.path[1:]; import django; print(django.__path__) 得到 ...

  5. 不让命令记录到history中

    先执行export HISTCONTROL=ignoresapce 然后再敲命令时在命令前面加一个空格

  6. Micro:Bit手柄试用之一MagicPad (解决蓝牙与gamePad包共存)

    前言 原创文章,转载引用务必注明链接.由于本人初次接触Micro:Bit,水平有限,如有疏漏,欢迎指正. Micro:Bit真好玩! DFRobot的论坛相关资料算是国内比较丰富的了,个人感觉MB比A ...

  7. es6 - 模板

    'use strict'; // es5 let name = 'mrs'; let qb = 20; function logs() { return 'goods!'; } let html = ...

  8. 身份证实名认证接口调用实例(PHP)

    基于php的身份证实名认证接口调用代码实例,身份证实名认证接口申请:https://www.juhe.cn/docs/api/id/103 <!--?php // +-------------- ...

  9. [翻译]MySQL 文档: Control Flow Functions(控制流函数)

    本文翻译自13.4 Control Flow Functions Table 13.6 Flow Control Operators 名称 描述 CASE Case 运算符 IF() if/else ...

  10. vector(可变数组) 用于UDP通信

    头文件: #include<vector.h> 然后,声明并初始化vctor数组. vector<char>  str(len); 其中len可以是变量或者常量.(其实用常量就 ...