一、.弹出的时候显示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. js遍历函数

    function each(arr, callback, thisp) { if (arr.forEach) {arr.forEach(callback, thisp);} else { for (v ...

  2. 机器学习3_EM算法与混合高斯模型

    ①EM算法: http://www.cnblogs.com/jerrylead/archive/2011/04/06/2006936.html 李航 <统计学习方法>9.1节 ②混合高斯模 ...

  3. POJ 3480 John [博弈之Nim 与 Anti-Nim]

    Nim游戏:有n堆石子,每堆个数不一,两人依次捡石子,每次只能从一堆中至少捡一个.捡走最后一个石子胜. 先手胜负:将所有堆的石子数进行异或(xor),最后值为0则先手输,否则先手胜. ======== ...

  4. python中mp3转wav(Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work")

    1.下载pydub:pip install pydub 2.下载与操作系统一致的ffmpeg:http://ffmpeg.org/download.html 3.解压后将下载的ffmpeg下的bin目 ...

  5. 如何使用Ext.create() 调用一个窗体

    Ext.define("Scripts.Code.QM.OutgoingQuality.OQC.ReinspRequest.view.DefectContentsDetailInfoWind ...

  6. SecureCRT的帮助文档

    [Help]->[Help Topics] Ubuntu:file:///usr/share/doc/scrt/SecureCRTHelp/SecureCRT.htm

  7. ios notification

    apps can use local or push notifications to let people know when interesting things happen, such as: ...

  8. Objective-C的self.用法的一些总结

    最近有人问我关于什么时候用self.赋值的问题, 我总结了一下, 发出来给大家参考. 有什么问题请大家斧正. 关于什么时间用self. , 其实是和Obj-c的存取方法有关, 不过网上很多人也都这么解 ...

  9. 【redis】java操作redis时,StringRedisTemplate的expire()方法的作用,什么时候使用

    java操作redis时,StringRedisTemplate的expire()方法的作用,什么时候使用 //重新设置过期时间为30分钟,刷新时间 redisTemplate.expire(MsOp ...

  10. 【spring cloud】子模块启动报错com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect

    spring cloud子模块启动报错 Caused by: java.lang.ClassNotFoundException: com.netflix.hystrix.contrib.javanic ...