Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report