[android] TextView 글자 크기 dp설정을 java코드로 설정하기 관련
=======================
=======================
=======================
이런식으로 형식을 지정해주면 됩니다.
TypedValue.COMPLEX_UNIT_DIP
TypedValue.COMPLEX_UNIT_SP
예)
_obj.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
_obj.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);
=======================
=======================
=======================
출처: https://www.androidpub.com/1323917
XML을 통해
=======================
=======================
=======================
출처: https://stackoverflow.com/questions/3061930/how-to-set-unit-for-paint-settextsize
Is it possible to change the unit for Paint.setTextSize()
? As far as I know, it's pixel but I like to set the text size in DIP for multiple screen support.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I know this topic is old and already answered but I would like to also suggest this piece of code:
int MY_DIP_VALUE = 5; //5dp int pixel= (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, MY_DIP_VALUE, getResources().getDisplayMetrics());
=======================
=======================
=======================