in my ui.xml, i have style like below
<ui:style src="../teststyle.css" />
if i want to programmatically use the style inside java file rather than ui.xml, in my widget how to call .setStyleName(..) as the css is obfuscated
You need to do the following steps to use the styles in your view class:
CssResource
in your view classinterface Style extends CssResource {
String myStyle();
}
@UiField
Style style;
type
attribute to your <ui:style>
element (the type must match the interface of step 1):<ui:style type="com.example.MyView.Style">
For each of the css classes you want to access in your view class you need to add a method to the Style
interface (as done with myStyle()
)
You can now access the style via the style
field (style.myStyle()
)
Hope that helps.