- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在实现一个拼写检查器,想知道是否有一种简单/明显的方法可以用不同颜色(例如红色)为某些文本加下划线。
我已设置好所有内容并使用以下代码加下划线(还设置了文本的颜色):
private AttributeSet getAttributeSet(Color foregroundColor) {
SimpleAttributeSet attrs = new SimpleAttributeSet();
StyleConstants.setForeground(attrs, foregroundColor);
StyleConstants.setUnderline(attrs, true);
}
上面的代码将单词设置为蓝色,但也用蓝色下划线。我需要能够更改下划线及其粗细。有什么想法吗?
谢谢,
最佳答案
使用例如这个 http://java-sl.com/tip_colored_strikethrough.html
只需修改一下即可实现下划线而不是删除线。
但根据我的经验,要突出显示拼写检查错误,最好定义自定义突出显示画家
另见 http://www.java2s.com/Code/Java/Swing-JFC/JTextPaneHighlightExample.htm
关于java - 使用 AttributeSet 在不同颜色下划线 StyleConstant,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9502654/
我无法理解如何在代码中实例化自定义布局。具体来说,我不知道如何定义所需的 AttributeSet 参数。 我已经阅读了官方文档,但无法全神贯注: http://developer.android.c
我有以下代码: private static boolean hasTargetStyle(AttributeSet attributes) { final Enumerati
我正在尝试获取一种颜色,在我的 AttributeSet 中设置,它引用在我的 colors.xml 中定义的颜色。 这是 colors.xml 的样子 ... #000000
我正在尝试通过 Pedram 从 this 实现更新的解决方案回答,但我不知道创建一个新的 CircleProgressBar 实例。它需要将AttributeSet作为参数传递,但是如何获取呢? C
我正在尝试找到一种方法来获取属性的原始未解析值。就此而言,我指的是布局文件中几乎完全相同的文本,而无需直接解析文件。 假设有一个像这样的 TextView: 我希望能够将 "?colorAccent
所以我的问题是,由于某种原因我的 AttributeSet 为空,我不知道如何解决这个问题。 public class MyDocumentFilter extends DocumentFilter
我已经覆盖了 this link 中给出的 EditText . 现在在我正在使用的布局中声明这个字段 我如何在任何这些构造函数中检索此提示值。 public ClearableEditText(
我的应用需要扩展 ImageView 的高度和宽度。我认为这应该有效: package my.android.test; public class TestImageView extends Imag
我想创建一个自定义类,当在 Android XML 文件中进行布局时,该类将颜色作为其属性之一。但是,颜色可以是一种资源,也可以是多种直接颜色规范之一(例如十六进制值)。是否有使用 Attribute
假设我有一个扩展 ViewGroup 的类 public class MapView extends ViewGroup 它包含在布局中 map_controls.xml 像这样 如何从 Attr
我有一个自定义组件,其中包含两个具有自定义大小设置方法的 TextView(两个 TextView 的比例约为 1:2)。由于这是 RelativeLayout 的子类,它没有 textSize 属性
什么是 Android 中的 AttributeSet? 如何将它用于我的自定义 View ? 最佳答案 一个较晚的答案,虽然是详细的描述,但对于其他人。 属性集(Android 文档) A coll
当使用 JTextPane 方法 insertIcon() 时,javadoc 指出 "...这在相关文档中表示为内容的一个字符。” 如何检索有关我插入的图标的信息?我已经尝试过 getCharact
我正在实现一个拼写检查器,想知道是否有一种简单/明显的方法可以用不同颜色(例如红色)为某些文本加下划线。 我已设置好所有内容并使用以下代码加下划线(还设置了文本的颜色): private Attrib
我想从 Misc widgets for Android platform 创建一个面板在运行时。 XmlPullParser parser = getResources().getXml(R.xm
我想在单击按钮时将 textView 添加到表格中。所以这就是我在 OnClickListener 中所做的事情: todoTable.addView(new TextView(this)); 我还想
我正在尝试在 Android 中编写一些代码以在 attrs.xml 文件的 AttributeSet 中设置参数。但是我收到“找不到资源”错误。 Java 代码 MainActivity.java
我正在尝试从 XML 资源文件中读取 AttributeSet。相关代码如下: //This happens inside an Activity Resources r = getR
好的,可以使用如下方式在 magento 中添加新的属性集: $entitySetup = new Mage_Eav_Model_Entity_Setup; $entitySetup->addAttr
我有一个自定义的 SeekBarPreference,它扩展了 DialogPreference。我正在构建自己的布局,但仍在使用父级的属性。 在代码部分,我正在检索 attr.getAttribu
我是一名优秀的程序员,十分优秀!