Android 为crouton库使用自定义样式
我正在使用Crouton lib() 现在,我想使用自定义样式而不是默认样式。我该怎么办 样式。警报是默认样式Android 为crouton库使用自定义样式,android,crouton,Android,Crouton,我正在使用Crouton lib() 现在,我想使用自定义样式而不是默认样式。我该怎么办 样式。警报是默认样式 Crouton.showText(this, "test", Style.ALERT); 我想使用这种风格: @风格: <style name="CroutonGreen"> <item name="android:layout_width">match_parent</item> <item name="android:la
Crouton.showText(this, "test", Style.ALERT);
我想使用这种风格:
@风格:
<style name="CroutonGreen">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:background">@color/color_pressed_buy_an_item</item>
<item name="android:gravity">center</item>
</style>
匹配父项
包装内容
@颜色/颜色\u按\u购买\u物品
居中
上面写着:
通常,您可以修改
显示持续时间
尺寸设置
要显示的文本的选项
自定义视图
外观与消失动画
显示图像
既然风格是调整面包片的一般切入点,那就自己去看看能用它做些什么吧
您可以尝试使用以下代码修改该类以更改背景颜色:
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;
}
高度像素、宽度像素和重力已根据您的样式正确设置
最后,在你的应用程序中,使用Style.CUSTOM调用你的面包块
Crouton.showText(this, "test", Style.CUSTOM);
谢谢你,坦佩!我喜欢面包片D