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 the effect of Racing Lantern in android

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article is about how to achieve the effect of racing lanterns in android. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Implementation steps:

Step 1: create a layout page

Step 2: write java code in activity

Package com.example.smallbag.autoscrolltext; import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.text.Html;import android.text.TextUtils;import android.text.method.LinkMovementMethod;import android.widget.TextView; public class MainActivity extends AppCompatActivity {@ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_main); TextView textView = (TextView) findViewById (R.id.textview) String html = "on the morning of January 25th, the political Bureau of the CPC Central Committee held its 12th collective study on the all-media era and the development of media integration at the people's Daily. Through People's Daily, I would like to extend New year's condolences and best wishes to journalists across the country. " / / CharSequence charSequence = Html.fromHtml (html); / / enable text to have html features, such as hyperlink textView.setText (html); textView.setMovementMethod (LinkMovementMethod.getInstance ()); / / add manual sliding function textView.setEllipsize (TextUtils.TruncateAt.valueOf ("MARQUEE")); / / add racing lantern function textView.setMarqueeRepeatLimit (Integer.MAX_VALUE); / / number of racing lantern scrolls, where the maximum textView.setSingleLine (true) has been set / / set to display textView.setFocusable (true) on a single line; / / get focus textView.setFocusableInTouchMode (true); / / ability to gain focus by touching}}

Setting the properties of textview can also be set directly in the layout file. The blogger cannot scroll when setting it in the layout file. The reason is unknown. Just pay attention.

Thank you for reading! This is the end of this article on "how to achieve the effect of racing lanterns in android". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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