android 判断软键盘

来源:互联网 发布:linux 配置网卡 编辑:程序博客网 时间:2024/04/29 08:49
思路就是判断界面布局的变化,如果弹出软件盘必定布局变化 从而起到判断软件弹起的作用。
软件盘其他问题连接http://blog.csdn.net/mynameishuangshuai/article/details/51567357
protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);//  add to onCreate method    Rect rectgle= new Rect();    Window window= getWindow();    window.getDecorView().getWindowVisibleDisplayFrame(rectgle);    sheight= rectgle.bottom;//} 


public boolean keyopen(){    Rect rectgle= new Rect();    Window window= getWindow();    window.getDecorView().getWindowVisibleDisplayFrame(rectgle);    int curheight= rectgle.bottom;    if (curheight!=sheight)    {        return true;    }    else    {        return false;    }}

0 0