欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

Android获取屏幕方向及键盘状态的小例子

程序员文章站 2023-12-04 21:25:22
复制代码 代码如下:  configuration config = getresources().getconfiguration();  if (config.orie...
复制代码 代码如下:

  configuration config = getresources().getconfiguration();
  if (config.orientation == configuration.orientation_landscape){
  //横屏,比如 480x320
  }else if(config.orientation == configuration.orientation_portrait){
  //竖屏 ,标准模式 320x480
  }else if(config.hardkeyboardhidden == configuration.keyboardhidden_no){
  //横屏,android123提示物理键盘滑出了
  }else if(config.hardkeyboardhidden == configuration.keyboardhidden_yes){
  //竖屏,键盘隐藏了
  }