1.软键盘弹出时不会改变布局(覆盖页面的效果)

android:windowSoftInputMode="adjustPan"
2、软键盘弹出时不会覆盖popuwindow
setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
3.popuwindow显示在页面底部,弹出时被软键盘顶
myInput.showAtLocation(findViewById(android.R.id.content),Gravity.BOTTOM,0,0);



4.源码
 4.1popupwindow的布局(自定义)
 public class MyInput extends PopupWindow {
  private Context context; private View view;
   public MyInput(Context context){
this.context=context;
init();
   }public void init(){
   LayoutInflater inflater=LayoutInflater.from(context);
view =inflater.inflate(R.layout.myinput,null);
this.setWidth(getScreenSize()[0]);
this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
setBackgroundDrawable(new ColorDrawable(0x00000000));
setOutsideTouchable(true);
setFocusable(true);
setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
setContentView(view);
}
@Override
public void showAsDropDown(View anchor) {
// TODO Auto-generated method stub
super.showAsDropDown(anchor);
showPopuWindow();
}
@Override
public void showAsDropDown(View anchor, int xoff, int yoff) {
// TODO Auto-generated method stub
super.showAsDropDown(anchor, xoff, yoff);
showPopuWindow();
}
@Override
public void showAsDropDown(View anchor, int xoff, int yoff, int gravity) {
// TODO Auto-generated method stub
super.showAsDropDown(anchor, xoff, yoff, gravity);
showPopuWindow();
}
@Override
public void showAtLocation(View parent, int gravity, int x, int y) {
// TODO Auto-generated method stub
super.showAtLocation(parent, gravity, x, y);
showPopuWindow();
}
private void showPopuWindow(){
setWindowBackgroundAlpha(0.8f);
if (mShowingListener!=null) {
mShowingListener.onShowing();
}
}
@Override
public void setOnDismissListener(OnDismissListener onDismissListener) {
setWindowBackgroundAlpha(1f);
super.setOnDismissListener(onDismissListener);
}
/**
* 控制窗口背景的不透明度 *
*/
private void setWindowBackgroundAlpha(float alpha) {
Window window = ((Activity) context).getWindow();
WindowManager.LayoutParams layoutParams = window.getAttributes();
layoutParams.alpha = alpha;
window.setAttributes(layoutParams);
}
public interface ShowingListener {
public void onShowing();
}
private MyInput.ShowingListener mShowingListener;
public void setShowingListener(MyInput.ShowingListener showingListener) {
this.mShowingListener = showingListener;
}
/*
* 获取屏幕的宽高
*/
public int[] getScreenSize(){
int[] size=new int[2];
DisplayMetrics dm=new DisplayMetrics();
WindowManager wm=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
wm.getDefaultDisplay().getMetrics(dm);
size[0]=dm.widthPixels;
size[1]=dm.heightPixels;
return size;
}
}

    

4.2activity里面的动态写popupwindow
shipin_pinglun.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//dibu.setVisibility(dibu.GONE);
        if (myInput==null){
myInput=new MyInput(SurfaceViewActivity.this);

myInput.setShowingListener(new MyInput.ShowingListener() {
@Override
public void onShowing() {
}
});
myInput.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
WindowManager.LayoutParams lp=getWindow().getAttributes();
lp.alpha = 1f;
getWindow().setAttributes(lp);
dibu.setVisibility(dibu.VISIBLE);
}
});
}
myInput.showAtLocation(findViewById(android.R.id.content),Gravity.BOTTOM,0,0);
}
});


popupwindow与软键盘的问题的更多相关文章

  1. 如何利用PopupWindow实现弹出菜单并解决焦点获取以及与软键盘冲突问题

    如何利用PopupWindow实现弹出菜单并解决焦点获取以及与软键盘冲突问题 如何利用PopupWindow实现弹出菜单并解决焦点获取以及与软键盘冲突问题 在android中有时候可能要实现一个底部弹 ...

  2. popupwindow中EditText获取焦点后自动弹出软键盘

    关于popupwindow中EditText获取焦点后自动弹出软键盘的问题,玩过手机qq或空间的童鞋应该知道,再点击评论时会弹出一个编辑框,并且伴随软键盘一起弹出是不是很方便啊,下面我们就来讲一下实现 ...

  3. Android PopupWindow中EditText获取焦点自动弹出软键盘

    公司的项目中要求在点击搜索的时候弹出一个搜索框,搜索框中有一个EditText,用于数据搜索关键字,要求在弹出PopupWindow的时候自动弹出软键盘,原以为只要写上着两行代码可以搞的问题: Inp ...

  4. (转载)PopuWindow和软键盘共存时的设置

    PopuWindow和软键盘共存时的设置 收藏 artshell 发表于 2年前 阅读 1499 收藏 10 点赞 2 评论 0 腾讯云上实验室 1小时搭建人工智能应用 让技术更容易入门>> ...

  5. Android中点击隐藏软键盘最佳方法——Android开发之路4

    Android中点击隐藏软键盘最佳方法 实现功能:点击EditText,软键盘出现并且不会隐藏,点击或者触摸EditText以外的其他任何区域,软键盘被隐藏: 1.重写dispatchTouchEve ...

  6. Android之弹出/隐藏系统软键盘

    Android弹出/隐藏系统软键盘的代码如下: InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT ...

  7. EditText获取和失去焦点,软键盘的关闭,和软键盘的显示和隐藏的监听

    软键盘显示和隐藏的监听: 注: mReplayRelativeLayout是EditText的父布局 //监听软键盘是否显示或隐藏 mReplayRelativeLayout.getViewTreeO ...

  8. Android -- 软键盘

    1. 应用启动后,自动打开软键盘 InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD ...

  9. form表单提交和ajax表单提交,关于移动端如何通过软键盘上的【搜索】和【前进】进行提交操作

    [文章来源]由于自己对于form研究甚少,所以一直用的都是AJAX进行提交,这次后台提出要用form提交,顺便深入研究一下:之前在做表单的时候,发现input可以通过设置不同的type属性,调用不同的 ...

随机推荐

  1. 嵌入式开发板iTOP-4412开发板移植CAN模块

    本文转自迅为:http://www.topeetboard.com 首先拷贝迅为提供的 libcanjni.tar.gz 压缩包到 android 源码的“iTop4412_ICS/device/sa ...

  2. [转]响应式表格jQuery插件 – Responsive tables

    本文转自:http://www.shejidaren.com/responsive-tables-for-bootstrap-3.html 这个Responsive tables jQuery插件依赖 ...

  3. uva 725 division(水题)——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABVMAAAOHCAIAAAClwESxAAAgAElEQVR4nOydybGturJFcQEPfgQu4A

  4. spring加载xml

    加载文件顺序 情形一:使用classpath加载且不含通配符 这是最简单的情形,Spring默认会使用当前线程的ClassLoader的getResource方法获取资源的URL,如果无法获得当前线程 ...

  5. 原创翻译-值得关注的10个python语言博客

    原文链接 原文链接的网页感觉网络不是很好,不容易上.我在这里就给大家做个翻译吧. 大家好,还记得我当时学习python的时候,我一直努力地寻找关于python的博客,但我发现它们的数量很少.这也是我建 ...

  6. CSU 1081 集训队分组

    题意:有n个学生,比了一场比赛,但是榜单看不到了.现在告诉你m段信息,每段信息的内容是(a,b),表示a的排名比b的高.问你能不能根据这些信息得出这场比赛的前k名. 思路:用拓扑排序找出一组符合k个人 ...

  7. redis 一二事 - 搭建集群缓存服务器

    在如今并发的环境下,对大数据量的查询采用缓存是最好不过的了,本文使用redis搭建集群 (个人喜欢redis,对memcache不感冒) redis是3.0后增加的集群功能,非常强大 集群中应该至少有 ...

  8. android ant 自动编译打包

    http://www.cnblogs.com/tankaixiong/archive/2010/11/24/1887156.html

  9. Android Activity的生命周期

    一.为什么要了解Activity的生命周期 activity is directly affected by its association withother activities, its tas ...

  10. kvm虚拟化管理平台WebVirtMgr部署-完整记录(安装Windows虚拟机)-(4)

    一.背景说明  在之前的篇章中,提到在webvirtmgr里安装linux系统的vm,下面说下安装windows系统虚拟机的操作记录: 由于KVM管理虚拟机的硬盘和网卡需要virtio驱动,linux ...