Auto Scroll Text view In Android 

 

Here You can make your textview Autoscroll easily in three step

Step:1

Make New class AutoScrollingTextView 

public class AutoScrollingTextView extends TextView {
    public AutoScrollingTextView(Context context, AttributeSet attrs,
            int defStyle) {
        super(context, attrs, defStyle);
    }

    public AutoScrollingTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public AutoScrollingTextView(Context context) {
        super(context);
    }

    @Override
    protected void onFocusChanged(boolean focused, int direction,
            Rect previouslyFocusedRect) {
        if (focused) {
            super.onFocusChanged(focused, direction, previouslyFocusedRect);
        }
    }

    @Override
    public void onWindowFocusChanged(boolean focused) {
        if (focused) {
            super.onWindowFocusChanged(focused);
        }
    }

    @Override
    public boolean isFocused() {
        return true;
    }
}

Step:2

And Change Text View in Xml File LIke

 <com.app.utility.AutoScrollingTextView
            android:id="@+id/tvGroup"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="5dp"
            android:layout_marginTop="8dp"
            android:layout_weight="2.5"
            android:ellipsize="marquee"
            android:fadingEdge="horizontal"
            android:lines="1"
            android:marqueeRepeatLimit="marquee_forever"
            android:scrollHorizontally="true"
            android:singleLine="true"
            android:textSize="18sp" />

Step:3

 In main actvity class or Adpater Change Textview Like

AutoScrollingTextView  t1=(AutoScrollingTextView ) findviewby(R.id.tvGroup);

 

By:Makhdum

Recent Comments

0 Comments

Sign In To Leave a Comment

Type your Comment below and click to send comment



error: function(jqXHR, textStatus, errorThrown) { alert(errorThrown); }