Android TextView 个别文字字体颜色格式
16lz
2021-01-23
Android TextView 个别文字字体颜色格式
1.简单的办法,用Html来格式化字符
Java代码
http://ghostfromheaven.iteye.com/blog/751099 转自
1.简单的办法,用Html来格式化字符
Java代码
- import android.app.Activity;
- import android.os.Bundle;
- import android.text.Html;
- import android.widget.TextView;
- public class AndroidFronColorTest extends Activity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- TextView htmlFormateTextView = (TextView)findViewById(R.id.testTextView);
- String source = "这只是一个测试,测试下划线、斜体字、红色字的格式";
- htmlFormateTextView.setText(Html.fromHtml(source));
- }
- }
http://ghostfromheaven.iteye.com/blog/751099 转自
更多相关文章
- android代码常识
- 登录+注册界面的实现(代码)
- 通过代码设置Android联系人的头像
- Android下MP3播放器的实现源代码02
- Android下MP3播放器的实现源代码03
- Android Audio代码分析21 - 创建AudioEffect对象
- Android Drawable 在代码中实现android:tint效果
- Android Chromium的标题代码运行路径