달력

5

« 2024/5 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
728x90
반응형
안드로이드 - TextView 전광판 기능 사용법

TextView 에서 문자열이 오른쪽에서 왼쪽으로 흐르게 표시되는 전광판 기능을 사용하는 방법은 다음과 같습니다.

* 아래와 같이 TextView 를 layout.xml 에 정의한다.

- TextView 에 입력된 문자열의 길이가 일정 길이 이상일 때에만 TextView 의 전광판 기능을 사용할 수 있다.

<TextView android:id="@+id/txtInfoMessage"

android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, TestTextViewActivity! This is not my fault and send me to bye. welcome to earth."
android:ellipsize="marquee"
android:scrollHorizontally="true"
android:focusable="true"
android:focusableInTouchMode="true"
/>

* layout.xml 을 사용하는 Activity 가 생성될 때에 아래의 코드를 추가한다.

m_txtInfoMessage = (TextView)findViewById( R.id.txtInfoMessage );
m_txtInfoMessage.setSelected( true );

참고로 위와 같이 실행하면 TextView 에 설정된 문자열이 3번 정도 옆으로 흐르다가 흐름을 멈추게 된다. 무한 반복으로 전광판 기능을 사용하고 싶으면 TextView 에 아래의 항목을 추가하면 된다.

android:marqueeRepeatLimit="marquee_forever"

728x90
반응형
:
Posted by mapagilove