关于TextView文字下划线
2015-11-27 15:13
99 查看
一丶Java代码中实现
<img src="https://img-blog.csdn.net/20151208143036732?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />package com.pry.textviewdemo; import android.app.Activity; import android.os.Bundle; import android.text.Html; import android.widget.TextView; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //初始化控件 TextView tv = (TextView) findViewById(R.id.tv); //设置文字下划线 tv.setText(Html.fromHtml("<u>hello world</u>"));
<span style="white-space:pre"> </span>/*
<span style="white-space:pre"> tv.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG ); //下划线<span style="white-space:pre"> </span>tv.getPaint().setAntiAlias(true);//抗锯齿</span>
<span style="white-space:pre"> </span>*/}}二丶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"tools:context=".MainActivity" ><TextViewandroid:id="@+id/tv"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:text="@string/hello_world" /></RelativeLayout>
<?xml version="1.0" encoding="utf-8"?><resources><string name="hello_world"><u>hello world</u></string><img src="https://img-blog.csdn.net/20151208143036732?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" /></resources>三丶效果图
相关文章推荐
- 关于TextView文字下划线
- 关于TextView文字下划线
- 并发编程杂记
- 头像上传ASP.NET MVC实现-可拖动大小实时预览
- 1127
- 数据库扩展
- C++的基本数据类型
- AFNetworking实现程序重新启动时的断点续传
- c#中如何跨线程调用windows窗体控件?
- ReactNative 学习笔记Component 和createClass区别
- UNIX网络编程——记录上锁
- 随机数https://en.wikipedia.org/wiki/Linear_congruential_generator
- mysql树查询及分层级
- 高德地图的定位
- Flume入门样例
- jQuery-noConflict()
- 日志显示错误NIC Agent
- 平台客户端日志查看说明
- 第十六节 协议栈LED实验
- Oracle 定义变量总结(转)