본문 바로가기

Android

TextView 방송자막 형태 Scroll

main.xml

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

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:orientation="vertical" >

    <HorizontalScrollView 

        android:layout_width="wrap_content"

    android:layout_height="fill_parent">

   <TextView

       android:id="@+id/DisplayActivity_txt_playword"

       android:layout_width="wrap_content"

       android:layout_height="wrap_content"

       android:text="@string/hello"

       android:singleLine="true"

       android:background="#770000FF"

       android:textSize="70px" />

</HorizontalScrollView>

    <Button

        android:id="@+id/DisplayActivity_btn_play"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_marginTop="100dp"

        android:layout_marginLeft="100dp"

        android:text="Button" />


</RelativeLayout>


DisplayActivity.java

public class DisplayActivity extends Activity implements OnClickListener {

private Button mBtnPlay;

private TextView mTxtPlayWord;

    /** Called when the activity is first created. */

    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

        WindowManager.LayoutParams.FLAG_FULLSCREEN);        

        setContentView(R.layout.main);

        

        mBtnPlay = (Button)findViewById(R.id.DisplayActivity_btn_play);

        mBtnPlay.setOnClickListener(this);

        mTxtPlayWord = (TextView)findViewById(R.id.DisplayActivity_txt_playword);

        mTxtPlayWord.setTextColor(Color.RED);

        mTxtPlayWord.setText("잠시후 오후 4시 부터 방송을 할 예정입니다. 이번 프로그램은 어쩌고 저쩌고 이므로 많은 시청을 바랍니다.");

    }


    public void onClick(View v) {

switch ( v.getId() )  {

case R.id.DisplayActivity_btn_play:

Animation anim = AnimationUtils.loadAnimation(this, R.anim.animation);

anim.setDuration(48000);

mTxtPlayWord.setSelected(true);

mTxtPlayWord.setAnimation(anim);

break;

}

    }

}