Auto scrolling (horizontal running) TextView


It's follow-up post about my old post of "Implement auto-running TextView", to make a TextView horizontal scrolling automatically.

This video show how it tested on Android emulator running Android 7.0 Nougat API 24, in Multi-Window Mode also.



xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical"
tools:context="com.blogspot.android_er.androidautotextview.MainActivity">

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:text="http://android-er.blogspot.com/"
android:textStyle="bold"/>

android:id="@+id/scrollingtext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="40dp"
android:background="#D0D0D0"
android:text="http://android-er.blogspot.com/"

android:focusable="true"
android:focusableInTouchMode="true"
android:singleLine="true"
android:scrollHorizontally="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever"
/>




And set it selected in Java code.
package com.blogspot.android_er.androidautotextview;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

TextView scrollingText;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
scrollingText = (TextView)findViewById(R.id.scrollingtext);
scrollingText.setSelected(true);

}
}



Popular posts from this blog

OnePlus Releases OxygenOS 4.5 OTA For OnePlus 3 and OnePlus 3T

Report: Incredibly Accurate GPS Chips are Coming to Smartphones Next Year

Black Friday saw the lowest price yet for the Roomba j7 from iRobot.