public final class AttributeList extends Boxed
Used as follows. First, build your text up into a String and initialize the Layout with it. You'll also have to create the wrapper that will hold the list of Attributes that will be applied to that Layout.
layout = new Layout(cr); layout.setText(str); list = new AttributeList();Then, iterate over your text and for each span where you want formatting, create one or more Attributes and specify the ranges that each will apply. For instance, for a word starting at offset
15
and being
4
characters wide.
attr = new StyleAttribute(Style.ITALIC); attr.setIndexes(15, 4); list.insert(attr); attr = new ForegroundColorAttribute(0.1, 0.5, 0.9); attr.setIndexes(15, 4); list.insert(attr);etc, adding each one to the AttributeList. Finally, tell the Layout to use that list:
layout.setAttributes(list);and you're on your way.
Constructor and Description |
---|
AttributeList()
Create an AttributeList.
|
Modifier and Type | Method and Description |
---|---|
void |
insert(Attribute attr)
Insert an Attribute into this list.
|
void |
insertBefore(Attribute attr)
Insert an Attribute into this list.
|
public AttributeList()
public void insert(Attribute attr)
IllegalStateException
- If you attempt to reuse an Attribute that is already in an
AttributeList.public void insertBefore(Attribute attr)
insert()
except that the Attribute will come before other Attributes
already in the list possessing the same start index.IllegalStateException
- If you attempt to reuse an Attribute that is already in an
AttributeList.