• 4、中划线、下划线


    一、中划线

    1、在布局中无法完成,需要去Activity实现

    2、布局代码

    <TextView
    android:id="@+id/tv_4"
    android:text="小秦同学在上学"
    android:layout_marginTop="20dp"
    android:textColor="#000000"
    android:textSize="36sp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

    3、activity设置

         3.1声明TextView 

        private TextView mtv4;

         3.2代码

        //添加中划线
    //强制转换
    mtv4=(TextView) findViewById(R.id.tv_4);
    mtv4.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
    mtv4.getPaint().setAntiAlias(true);//去除锯齿

    二、下划线

    常规方法

    布局代码:

    <TextView
    android:id="@+id/tv_5"
    android:text="天哥在奔跑"
    android:textColor="#000000"
    android:textSize="36sp"
    android:layout_marginTop="20dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

    Activity代码:

       *声明TextView

        private TextView mtv5;

       *设置下划线

        //设置下划线
    mtv5=(TextView) findViewById(R.id.tv_5);
    mtv5.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);

    HTML方法:

    布局代码:

    //注意此时text里面是没有值
    <TextView
    android:id="@+id/tv_6"
    android:text=""
    android:textSize="36sp"
    android:textColor="#000000"
    android:layout_marginTop="20dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    </TextView>

    Activity代码:

       *声明TextView

       private TextView mtv6;

       *设置下划线

       //设置下划线
    mtv6=(TextView)findViewById(R.id.tv_6);
    mtv6.setText(Html.fromHtml("<u>小秦同学在上学</u>"));
  • 相关阅读:
    [No0000161]IDEA初步接触
    [No0000171]wpf 类层次结构Class Hierarchy
    [No0000160]常用C# 正则表达式大全
    [No000015D]【李笑来 笔记整理】个人商业模式升级
    thinkphp 系统变量
    thinkphp不读取.env文件的键对值
    thinkphp 模板变量输出替换和赋值
    thinkphp 视图view
    thinkphp 响应对象response
    Thinkphp 请求和响应
  • 原文地址:https://www.cnblogs.com/xiaoqing-ing/p/13068495.html
Copyright © 2020-2023  润新知