Saturday, 28 July 2018
Auto scrolling horizontal running TextView
Auto scrolling horizontal running TextView
Its 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.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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="http://android-er.blogspot.com/"
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="http://android-er.blogspot.com/"
android:focusable="true"
android_focusableInTouchMode="true"
android_singleLine="true"
android_scrollHorizontally="true"
android_ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever"/>
</LinearLayout>
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);
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment