Tuesday, December 15, 2009

User Interface 관련 고려사항

Dimension

px
Pixels - corresponds to actual pixels on the screen.

in
Inches - based on the physical size of the screen.

mm
Millimeters - based on the physical size of the screen.

pt
Points - 1/72 of an inch based on the physical size of the screen.

dp
Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp".

sp
Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.

이중 가장 많이 사용되는 것은 dp 와 sp 입니다. dp로 정하면 화면의 크기나, density 가 다른화면이라도 어느정도 시스템이 알아서 보정을 해주여 개발이 쉬어집니다.


Configuration 변경

아래의 주요 시스템 세팅 변경은 Activity 의 onConfigurationChanged으로 감지가 되어 실시간으로 프로그램이 대응하는 것이 가능합니다..
orientation: 스크린이 세로에서 가로로 바뀌는 변경사항.
keyboardHidden: 키보드가 보여지거나 숨겨지는 변경사항 .
fontScale: 사용자가 원하는 폰트의 크기를 변경하는 것.
locale: 사용자가 언어 세팅을 변경하는것.
keyboard: 키보드의 종류가 바뀌는 사항

이를 위해서는 Manifest 파일의 해단 Activity 의 옆에 아래와 같이 android:configChanges 를 먼저 선언합니다.
<activity android:name="RosaryList" android:configChanges="keyboardHidden|orientation"></activity>

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    [ ... Update any UI based on resource values ... ]
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        [ ... React to different orientation ... ]
    }
    if (newConfig.keyboardHidden == Configuration.KEYBOARDHIDDEN_NO) {
        [ ... React to changed keyboard visibility ... ]
    }
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.