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. 【python】序列化和反序列化

    序列化可以理解为:把python的对象编码转换为json格式的字符串,反序列化可以理解为:把json格式字符串解码为python数据对象.在python的标准库中,专门提供了json库与pickle库 ...

  2. Vivado HLS初识---阅读《vivado design suite tutorial-high-level synthesis》(3)

    Vivado HLS初识---阅读<vivado design suite tutorial-high-level synthesis>(3) 优化lab1 1.创建工程,开启HLS 运行 ...

  3. JScript 正则表达式语法表

    字符 描述 \ 标记下一个字符是特殊字符或文字.例如,"n" 和字符 "n" 匹配."\n" 则和换行字符匹配.序列 "\\&qu ...

  4. 跟着未名学Office - 熟练使用WORD

    目录 第一章.Word之编辑篇. 1 第一节 页面布局... 1 第二节 格式编辑... 1 第三节 表.图.域... 5 第四节 审阅.保护... 7 第五节 *插入对像... 9 第二章.Word ...

  5. 跟着未名学 - 免费录屏工具ActivePresenter

    目录 简介... 1 录制屏幕... 1 编辑... 3 幻灯片... 3 时间轴... 4 对像... 4 导出视频... 4 未名 2017-7-17 简介 ActivePresenter 个人免 ...

  6. NIO基本操作

    NIO是Java 4里面提供的新的API,目的是用来解决传统IO的问题 NIO主要有三大核心部分:Channel(通道),Buffer(缓冲区), Selector(选择器) Channel(通道) ...

  7. STL基础--算法(不修改数据的算法)

    不修改数据的算法 count, min and max, compare, linear search, attribute // 算法中Lambda函数很常用: num = count_if(vec ...

  8. MongoDB查询结果存放入新的Collection

    第一种方法 var lst = db.visits_201501.find({ "url":/http:\/\/m.baidu.com\/application/ }); whil ...

  9. grafana 指标视图嵌入到其他html网页

    我们开发了一套管理平台用来监控整个系统环境的运行情况,但是在指标信息这块不想重新开发,而想直接拿grafana来用,刚开始的时候我们的管理平台和grafana是完全独立的,只能从我们平台跳转到graf ...

  10. Scrapy学习篇(三)之创建项目和Scrapy的安装

    安装Scrapy 了解了Scrapy的框架和部分命令行之后,创建项目,开始使用之前,当然是安装Scrapy框架了. 关于Scrapy框架的安装,请参考:https://cuiqingcai.com/5 ...