我想更改文本按钮的样式,例如我想添加背景图像,并且我想使用 GXT 3.0 更改背景颜色
谁能帮我一下
提前致谢
最佳答案
GXT 3 有一种更简洁的方式来处理此类要求。您必须使用Sencha 3中提供的Appearance API。以下是此过程中涉及的关键点。
- 外观接口(interface)、实现和替换
- 使用 CssResource 设置样式
- 使用ClientBundle获取css资源
- XTemplates 将样式/属性应用于标记
在这种情况下,您需要做的是实现 TextButtonCell 的外观(因为 TextButton 使用 TextButtonCell 作为外观)并使用 css Style 资源提供所需的样式(将实际的 .css 文件路径注释为源)。例如
public interface TextButtonResources extends ClientBundle
{
@Source("TextButton.css")
Style style();
}
然后将内置 TextButtonCell 外观替换为您的外观。
<replace-with class="fullyQualifiedNameToYourButtonCellAppearanceClass">
<when-type-is class="com.sencha.gxt.cell.core.client.ButtonCell.ButtonCellAppearance" />
</replace-with>
这篇博文详细介绍了这个概念 Ext GWT 3.0 Appearance Design
关于css - 如何在 Gxt 3.0 中更改 TextButton 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10849009/