它在这里说:
一般可以修改
文本显示持续时间尺寸设置选项以显示自定义视图外观和消失显示动画图像
由于样式是调整面包块的一般入口点,请亲自去看看可以用它做什么。
您可以尝试使用以下代码修改该类以更改背景颜色:
static {
ALERT = new Builder()
.setBackgroundColorValue(holoRedLight)
.build();
CONFIRM = new Builder()
.setBackgroundColorValue(holoGreenLight)
.build();
INFO = new Builder()
.setBackgroundColorValue(holoBlueLight)
.build();
CUSTOM = new Builder()
.setBackgroundColorValue(myColor)
.build();
}
我没有测试它,但我认为它应该工作。
然后在该类下面有以下代码:
public Builder() {
configuration = Configuration.DEFAULT;
paddingInPixels = 10;
backgroundColorResourceId = android.R.color.holo_blue_light;
backgroundDrawableResourceId = 0;
backgroundColorValue = NOT_SET;
isTileEnabled = false;
textColorResourceId = android.R.color.white;
textColorValue = NOT_SET;
heightInPixels = LayoutParams.WRAP_CONTENT;
widthInPixels = LayoutParams.MATCH_PARENT;
gravity = Gravity.CENTER;
imageDrawable = null;
imageResId = 0;
imageScaleType = ImageView.ScaleType.FIT_XY;
fontName = null;
fontNameResId = 0;
}
heightInPixels、widthInPixels、重力已经根据您的风格正确设置。
最后,在您的应用程序中,使用 Style.CUSTOM 调用您的面包块。
Crouton.showText(this, "test", Style.CUSTOM);