본문 바로가기
Resource

크기 (Dimension)

by 하드락 2022. 10. 2.

크기 (Dimension)

 

px (pixels) 화면 픽셀
in (inches) 물리적 인치
mm (millimeters) 물리적 밀리미터
pt (points) 물리적 포인터. 1pt 1인치의 1/72이다.
dp 또는 dip
(density-independent pixels)
화면의 밀도에 기초한 추상 단위.
1dp 160 dpi(dots per inch) 화면에서의 1px 대응된다.
, 인치당 160개의 점이 있는 디스플레이에서 1dp 1px 같다.
sp
(scaled-independent pixels)
스케일드 픽셀은 dp 비슷하지만, 사용자가 선택한 글꼴 설정에 따라 크기가 조절된다.

 

< /res/values/dimens.xml >

<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="textPixelSize">10px</dimen>
</resources>

 

코드에서 크기 값은 부동소수점(float)이다.

상기 리소스 파일에서 textPixelSize라는 크기 리소스의 실제 값을 얻는 예이다.

float myDimension = getResources().getDimension(R.dimen.textPixelSize);

 

'Resource' 카테고리의 다른 글

코드에서 리소스 사용하기  (0) 2022.10.02
단순 표시물 (Drawable)  (0) 2022.10.02
색상 (Color)  (0) 2022.10.02
문자열 (String)  (0) 2022.10.02
리소스 (Resource)  (0) 2022.10.02

댓글