您可以设置 UIOBject 的属性来清除 ListBox Primary CSS 主题,并根据需要添加自己的主题。
例如
ListBox list = new ListBox();
list.setStylePrimaryName("listBox");
属性 JavaDOC
"Sets the element's primary style name and updates all dependent style names."
注意:你需要在你的 ui 文件中添加这个 css,或者你可以创建一个 CSSResource 来引用你的 CSS 文件
interface ListBoundle extends ClientBundle{
ListBundle INSTANCE = GWT.create(ListBundle.class);
interface ListBoxCssResource extends CssResource {
String listBox();
}
@Source("package.listBox")
@CssResource.NotStrict
ListBoxCssResource css();
}
然后设置指向的属性
String listBox();
喜欢
ListBox list = new ListBox();
list.setStylePrimaryName(ListBoundle.ListBoxCssResource.listBox());
要在 UiBinder 中使用,您必须使用标签。
例如
<ui:style>
.gwt-ListBox{
background: #fff;
border: 1px solid #96CAEA;
}
</ui:style>
<g:ListBox styleName="{style.gwt-ListBox}"/>
但是使用外部资源更好。
有关更多信息,请阅读此