본문 바로가기

일하는 좀비/안드로이드

TextView와 Marquee처리에 대해서

아.. 춥다.
자판 두들기는것도 힘들정도로 춥구나... 쿨럭.

얼마전에 TextView에 문자 출력하다가 긴~ 문자를 어떻게 스크롤 시킬까 찾아본적이 있어서 기록.

일단 xml에 TextView레이아웃을 적어보자.. 끄적끄적..

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" >

    <TextView

            android:id="@+id/viewString"

            android:layout_width="match_parent"

            android:layout_height="match_parent"

            android:singleLine="true"

          android:ellipsize="marquee"

          android:marqueeRepeatLimit="marquee_forever"

          android:focusable="true"

          android:focusableInTouchMode="true"

            />

</LinearLayout>

 
붉은글씨가 문자 스크롤, 즉 marquee를 실행시키는 부분.
다만, 샘플코드에는 위에 두개만 설정이 되어있는데,
내부적으로 포커스가 가지 않으면 스크롤이 되지 않도록
TextView코드가 만들어져 있다는...( Orz 한참 찾았잖아) 

해서 아래 
android:focusable="true"

android:focusableInTouchMode="true" 
를 추가. 
가운데  
marqueeRepeatLimit 는 반복횟수. 즉 위 설정대로라면 무한뱅글. ㅋ
하지만... 이거... 너무 느려! 조절도 안돼고... 쿨럭.