您的位置:首页 > 移动开发 > Android开发

Android TextView 删除线

2016-02-19 14:04 323 查看

Android TextView 删除线

项目中使用到了,像一些购物性质的app经常会出现

废话不多说,详情见代码

1.简单的布局文件

<?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:gravity="center"
android:orientation="vertical" >

<TextView
android:id = "@+id/textView"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "1000元"/>

</LinearLayout>


2.在类文件中,通过getPaint().setFlags();来实现

/**
* 初始化UI数据
* */
private void initViews() {

textView = (TextView)findViewById(R.id.textView);

//添加删除线
textView.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);

}


3.同样的,setFlags()还有很多属性,下划线,波浪线等等,有兴趣可以自己尝试.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: