Jan 27, 2013

Implement auto scroll TextView in XML

Here demonstrate how to implement a auto scroll horizontally TextView in XML.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:scrollHorizontally="true"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit ="marquee_forever"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:text="Hello AndroidCoding: http://android-coding.blogspot.com/" />

</LinearLayout>

auto scroll horizontally TextView


If you define more than one marquee TextView in the layout, only the first one will run. To enable them run together, refer HERE.

No comments:

Post a Comment

Infolinks In Text Ads