2010년 12월 30일 목요일
[Android Course][English][Theme] - screenOrientation / Rotation
Android 'Rotation / screenOrientation' Let's examine each of the relevant information.
1. screenOrientation
(1) 'Xml' Setting
: "AndroidManifest.xml" in the Activity Tag "android: screenOrientation" When you are setting.
- Portrait: 'vertical' Show only
- Landscape: 'horizontal' Show only
- Norsensor: 'horizontal and vertical' transitions both X
- Sensor: 'Aspect' convert all O
=> Cons: phone 'Settings - System - Display - Automatic screen rotation feature and independent works.
In other words, the 'Auto Screen Painting' and 'Diable' rotation is set to'm in is the problem.
- Unspecified: 'Aspect' convert all O
=> Features: Pawn 'Settings - System - Display - Automatic screen rotation feature based on the works.
In other words, the 'Auto Screen Painting' and 'Diable' If you set the rotation does not work.
(2) 'Code' Setting
: Code on the "setRequestedOrientation ()" API to be used.
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
...ETC...
2. 'Rotation' NOTICE
: Android will support the screen rotation feature.
However, if there is any set, each time rotating existing Activity does not preserve the Data. In other words, the horizontal / vertical conversion while at the UI Activity of a newly drawn onDestroy () and onCreate () is being performed.
1) 'onDestroy() & onCreate()' How not to reload
- 'AndroidManifest.xml' Setting
: android:configChanges="keyboardHidden|orientation"
- 'Code' Setting
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
switch(newConfig.orientation) {
case Configuration.ORIENTATION_PORTRAIT:
.....working......
break;
case Configuration.ORIENTATION_LANDSCAPE:
.....working......
break;
}
}
: Activity is being reloaded because the screen size remains unchanged. Therefore, 'Code' section of the above would have to work.
2) 'onDestroy() & onCreate()' 호출 시, Data Backup 방법
- Screen rotation, Data Save.
: 'Public Object onRetainNonConfigurationInstance ()' on the screen, in turn, is to store the data coding.
public Object onRetainNonConfigurationInstance() {
HashMap<String, Object> DataBackup = null;
DataBackup = new HashMap<String, Object>();
...... Data Save Working.....
return DataBackup;
}
- 'OnCreate ()' call back, Data Loading.
: 'Public void onCreate (Bundle savedInstanceState)' call back, 'Data Loading' job is.
public void onCreate(Bundle savedInstanceState) {
....
Object obj = getLastNonConfigurationInstance()
if (obj != null) {
HashMap<String, Object> DataBackup = (HashMap<String, Object>) obj;
..... Data Loading .....
}
....
}
3. AVD(Android Virtual Device) Horizontal / vertical mode switching Tip
: Android aemyulreyiteoin AVD (Android Virtual Device) of the 'horizontal and vertical' transition [CTRL] + F11 or [CTRL] + F12 and pressed, the screen 'aspect' is turned into.
※ While pressing the Control key and continue pressing the key until you change aneuni attention.
: Function Key
[CTRL] + F11
[CTRL] + F12
On the numeric keypad [7] (numeric keypad [7] [NumLock] can be off work)
4. Screen rotation
1) Android 2.1 -Eclar
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
int orientation = display.getOrientation();
=> orientation == 0 : Vertical Mode
=> orientation == 1. Horizontal Mode
2) Android 2.2-Froyo
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
int rotation = display.getRotation();
=> Surface.ROTATION_0 : Vertical Mode
=> Surface.ROTATION_90 : Horizontal Mode
=> Surface.ROTATION_180 : Vertical Mode
=> Surface.ROTATION_270 : Horizontal Mode
In addition, inquiries, or questions, please contact us.
(joonryang@gmail.com)
피드 구독하기:
댓글 (Atom)
댓글 없음:
댓글 쓰기