您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
小编给大家分享一下android中常用UI控件TextView4如何实现rollingsubtitles效果加链接文字,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!
(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 <font color='blue'><a href='http://test.com'>Linux</a></font> 系统.太平洋电脑网提供Android手机大全全面服务信息,包含Android手机报价、参数、评测、比较";
CharSequence charsequence = Html.fromHtml(html);
textview.setText(charsequence);
//设置***灯效果
textview.setSingleLine(true);
textview.setEllipsize(TextUtils.TruncateAt.MARQUEE);
textview.setMarqueeRepeatLimit(-1);
//设置内填充
textview.setPadding(5, 5, 5, 5);
//设置宽度
textview.setFocusableInTouchMode(true);
textview.setFocusable(true);
//设置可以点击属性
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
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/textveiw" android:focusableInTouchMode="true" android:padding="10dp" > </TextView> </RelativeLayout>

看完了这篇文章,相信你对“android中常用UI控件TextView4如何实现rollingsubtitles效果加链接文字”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。