Auto Scrolling (Horizontal Running) Textview

Posted on

It’s follow-up postal service virtually my former postal service of “Implement auto-running TextView“, to brand a TextView horizontal scrolling automatically.

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

<?xml version="1.0" encoding="utf-8"?> <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:padding="16dp"     android:orientation="vertical"     tools:context="com.blogspot.android_er.androidautotextview.MainActivity">      <TextView         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_margin="20dp"         android:layout_gravity="center_horizontal"         android:autoLink="web"         android:text="https://rootandroid.org//"         android:textStyle="bold"/>      <TextView         android:id="@+id/scrollingtext"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:textSize="40dp"         android:background="#D0D0D0"         android:text="https://rootandroid.org//"          android:focusable="true"         android:focusableInTouchMode="true"         android:singleLine="true"         android:scrollHorizontally="true"         android:ellipsize="marquee"         android:marqueeRepeatLimit ="marquee_forever"/>  </LinearLayout>  

And laid upward it selected inwards Java code.

package com.blogspot.android_er.androidautotextview;  import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.TextView;  populace shape 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);      } }