本文整理匯總了Java中android.content.res.Configuration.ORIENTATION_UNDEFINED屬性的典型用法代碼示例。如果您正苦於以下問題:Java Configuration.ORIENTATION_UNDEFINED屬性的具體用法?Java Configuration.ORIENTATION_UNDEFINED怎麽用?Java Configuration.ORIENTATION_UNDEFINED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.content.res.Configuration
的用法示例。
在下文中一共展示了Configuration.ORIENTATION_UNDEFINED屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getOrientation
/**
* Returns the current device orientation.
*/
static String getOrientation(Context context) {
int orientation = context.getResources().getConfiguration().orientation;
switch(orientation)
{
case Configuration.ORIENTATION_LANDSCAPE:
return "Landscape";
case Configuration.ORIENTATION_PORTRAIT:
return "Portrait";
case Configuration.ORIENTATION_SQUARE:
return "Square";
case Configuration.ORIENTATION_UNDEFINED:
return "Unknown";
default:
return null;
}
}
示例2: drawResizedBitmap
private void drawResizedBitmap(final Bitmap src, final Bitmap dst) {
Display getOrient = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int orientation = Configuration.ORIENTATION_UNDEFINED;
Point point = new Point();
getOrient.getSize(point);
int screen_width = point.x;
int screen_height = point.y;
Log.d(TAG, String.format("screen size (%d,%d)", screen_width, screen_height));
if (screen_width < screen_height) {
orientation = Configuration.ORIENTATION_PORTRAIT;
mScreenRotation = -90;
} else {
orientation = Configuration.ORIENTATION_LANDSCAPE;
mScreenRotation = 0;
}
Assert.assertEquals(dst.getWidth(), dst.getHeight());
final float minDim = Math.min(src.getWidth(), src.getHeight());
final Matrix matrix = new Matrix();
// We only want the center square out of the original rectangle.
final float translateX = -Math.max(0, (src.getWidth() - minDim) / 2);
final float translateY = -Math.max(0, (src.getHeight() - minDim) / 2);
matrix.preTranslate(translateX, translateY);
final float scaleFactor = dst.getHeight() / minDim;
matrix.postScale(scaleFactor, scaleFactor);
// Rotate around the center if necessary.
if (mScreenRotation != 0) {
matrix.postTranslate(-dst.getWidth() / 2.0f, -dst.getHeight() / 2.0f);
matrix.postRotate(mScreenRotation);
matrix.postTranslate(dst.getWidth() / 2.0f, dst.getHeight() / 2.0f);
}
final Canvas canvas = new Canvas(dst);
canvas.drawBitmap(src, matrix, null);
}
示例3: setLockRotation
private void setLockRotation(boolean avpLock) {
Display display = getWindowManager().getDefaultDisplay();
int rotation = display.getRotation();
if (DBG) Log.d(TAG, "rotation status: " + rotation);
boolean systemLock;
try {
systemLock = 1 != Settings.System.getInt(getContentResolver(), Settings.System.ACCELEROMETER_ROTATION);
} catch (SettingNotFoundException e) {
systemLock = false;
}
if (DBG) Log.d(TAG, "avpLock: " + avpLock + " systemLock: " + systemLock);
if (avpLock || systemLock) {
int tmpOrientation = getResources().getConfiguration().orientation;
int wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
if (tmpOrientation == Configuration.ORIENTATION_LANDSCAPE) {
if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90)
wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
else
wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
setRequestedOrientation(wantedOrientation);
}
else if (tmpOrientation == Configuration.ORIENTATION_PORTRAIT || tmpOrientation == Configuration.ORIENTATION_UNDEFINED) {
if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90)
wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
else
wantedOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
setRequestedOrientation(wantedOrientation);
}
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
}