我可以在Android布局xml文件中定义中间行文本 [英] can I define middle-lined text in an Android layout xml file

查看:114
本文介绍了我可以在Android布局xml文件中定义中间行文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Android布局xml文件中定义中线(删除线)文本?

How can I define middle-lined(strikethrough) text in an Android layout xml file?

推荐答案

要删除线,可以使用背景图像创建删除线效果:

To strike through, you can use a background image to create the strikethrough effect:

 android:background="@drawable/strike_through"

strike_through可绘制对象是9个补丁的图像,其中一条线穿过中间.这是实现它的最简单方法.

Where strike_through drawable is a 9-patch image that keeps a line through the middle. This is the easiest way to implement it.

或者您可以通过编程方式做到这一点.

or you can do it programatically as this.

TextView t = (TextView) findViewById(R.id.text);
t.setText("Text here");
t.setPaintFlags(t.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

这篇关于我可以在Android布局xml文件中定义中间行文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆