Android方法判断当前有没有切换屏
1个回答
2016-10-22
展开全部
android api提供了方法判断是否横竖屏:
public boolean isScreenChange() {
Configuration mConfiguration = this.getResources().getConfiguration(); //获取设置的配置信息
int ori = mConfiguration.orientation ; //获取屏幕方向
if(ori == mConfiguration.ORIENTATION_LANDSCAPE){
//横屏
return true;
}else if(ori == mConfiguration.ORIENTATION_PORTRAIT){
//竖屏
return false;
}
return false;
}
public boolean isScreenChange() {
Configuration mConfiguration = this.getResources().getConfiguration(); //获取设置的配置信息
int ori = mConfiguration.orientation ; //获取屏幕方向
if(ori == mConfiguration.ORIENTATION_LANDSCAPE){
//横屏
return true;
}else if(ori == mConfiguration.ORIENTATION_PORTRAIT){
//竖屏
return false;
}
return false;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询