Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize rollingsubtitles effect with linked text by UI Control TextView4 in android

Shulou Source: shulou.com Published: 2022-06-02 11:53:40 10月05日 Update

Editor to share with you how the commonly used UI control TextView4 in android to achieve rollingsubtitles effect plus link text, I hope you have something to gain after reading this article, let's discuss it together!

(1) Mainactivity.java

Package com.example.android_textview_rollingsubtitles;import java.sql.Wrapper;import android.os.Bundle;import android.app.Activity;import android.text.Html;import android.text.TextUtils;import android.text.TextUtils.TruncateAt;import android.text.method.LinkMovementMethod;import android.view.Menu;import android.widget.TextView;public class MainActivity extends Activity {private TextView textview; @ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_main) Textview = (TextView) this.findViewById (R.id.textveiw); String html = "Android Linux system. Pacific computer Network provides Android mobile phone complete service information, including Android mobile phone quotation, parameters, evaluation, comparison "; CharSequence charsequence = Html.fromHtml (html); textview.setText (charsequence); / / set * lamp effect textview.setSingleLine (true); textview.setEllipsize (TextUtils.TruncateAt.MARQUEE); textview.setMarqueeRepeatLimit (- 1) / / set the inner fill textview.setPadding (5, 5, 5, 5); / / set the width textview.setFocusableInTouchMode (true); textview.setFocusable (true); / / you can click the property textview.setMovementMethod (LinkMovementMethod.getInstance ());} @ Override public boolean onCreateOptionsMenu (Menu menu) {/ / Inflate the menu This adds items to the action bar if it is present. GetMenuInflater () .inflate (R.menu.main, menu); return true;}}

(2) activity.xml

After reading this article, I believe you have a certain understanding of "how to achieve rollingsubtitles effect and link text by TextView4, a common UI control in android". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!

Tags: Effects commonly used controls text links mobile phones articles information parameters Daquan finished width attributes mobile phone quotes more computers computer networks knowledge systems Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux NVidia MariaDB Shulou Tech Info macOS