Android

Android TextView 내부 String 길이

plandis 2015. 6. 19. 19:58

TextView의 Text길이가 길때 Text의 length 뿐만아니라 실제로 그려지는 길이를 알고 싶을 때가 있는데 이때 사용하면 유용하다.

view.getPaint();

Paint Class

float measureText(String text)
Return the width of the text.
float measureText(CharSequence text, int start, int end)
Return the width of the text.
float measureText(String text, int start, int end)
Return the width of the text.
float measureText(char[] text, int index, int count)
Return the width of the text.

 

* view에 Text를 할당 한 뒤 사용한다.