ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [Android] TextView
    개발노하우/others. 2010. 4. 13. 11:30
    TextView의 android:text 특성 [각주:1]을 지정하는 두 가지 방식이 있는데 다음과 같다.

    1. 문자열 지정
    <TextView
                android:id="@+id/TextView01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Some sample text here" />

    2. strings.xml 자원파일 참조 [각주:2]- <string name="sample_text">Sample Text</stirng>
    <TextView
                android:id="@+id/TextView01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/sample_text" />

    ■ TextView의 너비(width)를 픽셀 단위 대신 em 단위로 설정할 수 있다.(1ems는 12pt)
        - maxEms, minEms 특성을 제공
    ■ TextView의 높이(height)를 픽셀 단위 대신 line 단위로 지정 할 수 있다.
        - maxLines, minLines 특성을 제공

    <TextView
                android:id="@+id/TextView00"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
    android:lines="2"
    android:ems="12"
                android:text="@string/autolink_test" />

    ■ 이 TextView는 텍스트가 너무 길면 위젯의 끝에서 그냥 잘려버린다.
       그렇게 하는 대신 ellipsize특성을 이용해 마지막 몇 글자를 말줄임표(...)로 대체되게 할 수 있다.

    1. Reference by android.widget [본문으로]
    2. http://edkoon.tistory.com/313 [본문으로]
Designed by Tistory.