原文:Windows Phone开发(6):处理屏幕方向的改变 俺们都知道,智能手机可以通过旋转手机来改变屏幕的显示方向,更多的时候,对于屏幕方向的改变,我们要做出相应的处理,例如,当手机屏幕方向从纵向变为横向时,可能要重新排列页面上的控件以适应显示区域的变化. 前面我们讨论过,Silverlight for Windows Phone的页面布局有三个常用的布局控件,那么,当屏幕方向改变后,我们所做的对布局的更改基础上是基于这几个容器进行的操作. 本文我将通过三个示例来分别说明. 开始之前,先说…
正常的判断屏幕方向的代码: /** 获取屏幕是否是竖屏 * @return */ @SuppressLint("SwitchIntDef") public boolean isScreenPortrait(){ int or = getRequestedOrientation(); switch (or) { case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE :// 横屏 case ActivityInfo.SCREEN_ORIENTATIO…
(博客部分内容参考Windows phone开发文档) Windows phone的屏幕方向是利用Windows phone设备的方向传感器提供的数据实现切换的. Windows Phone支持纵向和横向屏幕方向,其中横向屏幕包括横向朝左和横向朝右. 应用的默认方向为纵向,如果要想应用支持纵向和横向,要在 XAML 或代码中将SupportedOrientations属性设置为PortraitOrLandscape. Windows phone开发中还提供了OrientationChanged事…
void android.app.Activity.setRequestedOrientation(int requestedOrientation) 官方API解释: Change the desired orientation of this activity. If the activity is currently in the foreground or otherwise impacting the screen orientation, the screen will…