XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="15dp">

    <!--给文字添加中划线-->
    <TextView
        android:id="@+id/TextView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="给文字添加中划线"
        android:textSize="30sp"
        android:textColor="#00dd99"
        android:layout_marginTop="15dp"/>
    <!--给文字添加下划线-->
    <TextView
        android:id="@+id/TextView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="给文字添加下划线"
        android:textSize="30sp"
        android:textColor="#00dd99"
        android:layout_marginTop="15dp"/>

</LinearLayout>

Activity:

package com.example.prize.mydemo1;

import android.graphics.Paint;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

public class Main5Activity extends AppCompatActivity {
    TextView textView1,textView2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main5);
        textView1 = (TextView)findViewById(R.id.TextView1);
        textView2 =(TextView)findViewById(R.id.TextView2);
        textView1.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);//中划线
        textView1.getPaint().setAntiAlias(true); //去掉锯齿

        textView2.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线

    }
}

运行效果:

android TextView 例子代码(文字中划线、文字下划线)的更多相关文章

  1. android TextView 例子代码(文字图片、文字省略、文字滚动)

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  2. React-Native 之 GD (二十)removeClippedSubviews / modal放置的顺序 / Android 加载git图\动图 / 去除 Android 中输入框的下划线 / navigationBar

    1.removeClippedSubviews 用于提升大列表的滚动性能.需要给行容器添加样式overflow:’hidden’.(Android已默认添加此样式)此属性默认开启 这个属性是因为在早期 ...

  3. iOS - UIButton设置文字标题下划线以及下划线颜色

    创建button设置可以折行显示 - (void)viewDidLoad { [super viewDidLoad]; UIButton * button = [[UIButton alloc] in ...

  4. python中那些双下划线开头得函数和变量--转载

    Python中下划线---完全解读     Python 用下划线作为变量前缀和后缀指定特殊变量 _xxx 不能用'from module import *'导入 __xxx__ 系统定义名字 __x ...

  5. python中那些双下划线开头得函数和变量

    Python中下划线---完全解读     Python 用下划线作为变量前缀和后缀指定特殊变量 _xxx 不能用’from module import *’导入 __xxx__ 系统定义名字 __x ...

  6. SQL搜索下划线,like中不能匹配下划线的问题

    最近在检测天气预报15天查询网 站(http://tqybw.net)时的URL时,发现页面中有很些404页,分析发现,是请求地址的能参数中多了下划线“_”,而rewrite规 则中并没有配这样的规则 ...

  7. json字符串中key值下划线命名转换为驼峰命名

    json字符串中key值下划线命名转换为驼峰命名: 例如: 原json串: String json= "{'user_name':'ok','user_sex':0,'object_info ...

  8. python python中那些双下划线开头的那些函数都是干啥用用的

    1.写在前面 今天遇到了__slots__,,所以我就想了解下python中那些双下划线开头的那些函数都是干啥用用的,翻到了下面这篇博客,看着很全面,我只了解其中的一部分,还不敢乱下定义. 其实如果足 ...

  9. 去掉VS2010代码中文注释的红色下划线

    VS2010代码中文注释出现红色下划线,代码看上去很不美观,发现是由于安装Visual Assist X插件造成的. 解决办法:打开VAX的Options对话框,取消Advanced --> U ...

随机推荐

  1. AI硬件 XPU

    市场对人工智能的热情持续高涨,特别是硬件领域.人工智能将成为下一个大风口,首当其冲的就包括硬件, 在图像语音识别.无人驾驶等人工智能领域的运用层面,图形处理器 (GPU)正迅速扩大市场占比,而谷歌专门 ...

  2. Variant <-->Record Variant <-->Stream

    //     TARec   --->   Variantfunction RecordToVariant(value:TParamRecord):OleVariant;var P:Pointe ...

  3. ASP.NET中使用JSON方便实现前台与后台的数据交换

    ASP.NET中使用JSON方便实现前台与后台的数据交换 发表于2014/9/13 6:47:08  8652人阅读 分类: ASP.NET Jquery extjs 一.前台向后台请求数据 在页面加 ...

  4. 禁用触发器的N种方法

    一.禁用和启用单个触发器 禁用: ALTER TABLE trig_example DISABLE TRIGGER trig1 GO   恢复: ALTER TABLE trig_example EN ...

  5. docker配置ftp服务器

    docker run --name ftp_server -d -v ~/Projects/ftp:/home/vsftpd -p : -p : -p -:- -e FTP_USER=ftp -e F ...

  6. QT使用SQLite

    在QT的widget中用tableview显示sqlite数据库表中的内容. 用QTcreator创建一个基于Widget类的窗口,再拖一个tableview到widget中,保存. 1.在widge ...

  7. 黄聪:TortoiseGit(乌龟git)保存用户名密码的方法

    1.在项目文件夹右键--tortoiseGit--设置 2.编辑全局.git/config 3.加上这行代码 里面会有你先前配好的name 和email,只需在下面加一行 [credential] h ...

  8. 【微软版本】redis 安装启动及设置密码<windows>

    redis 安装启动及设置密码<windows>   redis 1. 安装 1.1 下载解压包,直接解压到任意路径下即可 windows下载地址:ttps://github.com/MS ...

  9. java中的强,软,弱,虚引用

    引用的应用场景 我们都知道垃圾回收器会回收符合回收条件的对象的内存,但并不是所有的程序员都知道回收条件取决于指向该对象的引用类型.这正是Java中弱引用和软引用的主要区别. 如果一个对象只有弱引用指向 ...

  10. 【Linux】使用fsck对磁盘进行修复

    在后台执行 磁盘修复 nohup fsck.ext3 -y /dev/sdb1 > /root/fsck.log 2>&1 & 使用nohup和& 让进程在后台执行 ...