XML:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:orientation="vertical"
  6. android:padding="15dp">
  7. <!--给文字添加中划线-->
  8. <TextView
  9. android:id="@+id/TextView1"
  10. android:layout_width="wrap_content"
  11. android:layout_height="wrap_content"
  12. android:text="给文字添加中划线"
  13. android:textSize="30sp"
  14. android:textColor="#00dd99"
  15. android:layout_marginTop="15dp"/>
  16. <!--给文字添加下划线-->
  17. <TextView
  18. android:id="@+id/TextView2"
  19. android:layout_width="wrap_content"
  20. android:layout_height="wrap_content"
  21. android:text="给文字添加下划线"
  22. android:textSize="30sp"
  23. android:textColor="#00dd99"
  24. android:layout_marginTop="15dp"/>
  25. </LinearLayout>

Activity:

  1. package com.example.prize.mydemo1;
  2. import android.graphics.Paint;
  3. import android.support.v7.app.AppCompatActivity;
  4. import android.os.Bundle;
  5. import android.widget.TextView;
  6. public class Main5Activity extends AppCompatActivity {
  7. TextView textView1,textView2;
  8. @Override
  9. protected void onCreate(Bundle savedInstanceState) {
  10. super.onCreate(savedInstanceState);
  11. setContentView(R.layout.activity_main5);
  12. textView1 = (TextView)findViewById(R.id.TextView1);
  13. textView2 =(TextView)findViewById(R.id.TextView2);
  14. textView1.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);//中划线
  15. textView1.getPaint().setAntiAlias(true); //去掉锯齿
  16. textView2.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线
  17. }
  18. }

运行效果:

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. RedHat6.5安装单机flume1.6

    版本号: RedHat6.5   JDK1.8   apache-flume-1.6.0 1.apache-flume-1.6.0-bin.tar.gz 下载 官网下载地址:http://archiv ...

  2. Excel技巧--分类求和与空白批量填充

    分类求和: 当我们要对以上多个分类空白求和时,可以巧用Alt+=键: 1.选择对应要求和的列: 2.点击“查找与选择”下拉列,选择“定位条件”,对话框选择“空值”,点确定.将列中的空白单元格选好: 3 ...

  3. 瑞萨S5D9实现UART环形缓冲

    队列的常见两种形式,普通队列和环形队列: 普通队列: 环形队列: 当有大量数据的时候,我们不能存储所有的数据,那么计算机处理数据的时候,只能先处理先来的,那么处理完后呢,就会把数据释放掉,再处理下一个 ...

  4. mysql++ 3.2.3 源码安装

    https://tangentsoft.com/mysqlpp/home 下载 wget https://tangentsoft.com/mysqlpp/releases/mysql++-3.2.3. ...

  5. 网页如何检查浏览器是否安装flash插件

    如果页面需要加载flash插件并且需要提示用户flash下载,这里有个官方很好的js文件只要引用就可以实现 //v1.7 // Flash Player Version Detection // De ...

  6. Redis的5中数据类型

    Radis的作用相信既然然就就知道她的作用,但是对于刚开始对radis学习的初学者来说,理解起来比较费劲.这里就从开始一步步认识radis 首先要知道radis是存在内存中的数据,所以读取速度回更改, ...

  7. SSH的配置文件

    Hibernate: xxx.hbm.xml   ,作用:类的属性和表的列建立映射关系,主键策略,多表查询等 hibernate.cfg.xml ,核心配置文件,数据库配置信息,加载xxx.hbm.x ...

  8. NodeJs之配置文件管理

    查询了一些资料,我使用nodejs的object作为配置文件,首先定义一个module config.js: var config = { uploadPath: "E:\\" } ...

  9. 学习笔记之Introduction to Data Visualization with Python | DataCamp

    Introduction to Data Visualization with Python | DataCamp https://www.datacamp.com/courses/introduct ...

  10. [转]PLSQL 记住密码