Android屏幕显示

显示相关

屏幕朝向

https://developer.android.com/reference/android/content/res/Configuration.html#orientation
具体区别如下:

activity.getResources().getConfiguration().orientation获取的是当前设备的实际屏幕方向值,可以动态地根据设备的旋转或用户的操作进行改变。例如,当用户将设备从纵向旋转到横向时,获取到的屏幕方向值也会相应地改变。

Manifest中配置的orientation是用于指定活动的默认方向,即在没有其他因素影响时,活动应该显示的方向。它可以有以下几个值:

portrait:纵向(竖屏)方向。
landscape:横向(横屏)方向。
sensor:根据设备的旋转自动调整方向。
user:根据用户的偏好自动调整方向。

这个配置可以在Manifest文件中的标签中进行设置。但是,它只是一个默认值,实际的屏幕方向还会受到其他因素的影响,如设备旋转、用户操作等。
activity.getResources().getConfiguration().orientation获取的是当前设备的屏幕方向值,而Manifest中配置的orientation是用于指定活动的默认方向。

总结来说,activity.getResources().getConfiguration().orientation获取的是当前设备的实际屏幕方向值,而Manifest中配置的orientation是活动的默认方向,但实际方向可能会根据设备和用户的操作而改变。

Android屏幕朝向

ORIENTATION_UNDEFINED:未指定
ORIENTATION_PORTRAIT:竖屏
ORIENTATION_LANDSCAPE:横屏
ORIENTATION_SQUARE:正方形

/** Constant for {@link #orientation}: a value indicating that no value has been set. */
public static final int ORIENTATION_UNDEFINED = 0;
/** Constant for {@link #orientation}, value corresponding to the
 * port
 * resource qualifier. */
public static final int ORIENTATION_PORTRAIT = 1;
/** Constant for {@link #orientation}, value corresponding to the
 * land
 * resource qualifier. */
public static final int ORIENTATION_LANDSCAPE = 2;
/** @deprecated Not currently supported or used. */
@Deprecated public static final int ORIENTATION_SQUARE = 3;

你可能感兴趣的:(android,android)