use of android.graphics.drawable.GradientDrawable in project Shuttle by timusus.
the class SuggestedHeaderButton method init.
void init() {
backgroundDrawable = new GradientDrawable();
backgroundDrawable.setCornerRadius(ResourceUtils.toPixels(2));
setBackground(backgroundDrawable);
}
use of android.graphics.drawable.GradientDrawable in project Tangram-Android by alibaba.
the class LinearScrollView method setViewColor.
private void setViewColor(View view, int color) {
if (view.getBackground() instanceof GradientDrawable) {
GradientDrawable drawable = (GradientDrawable) view.getBackground().mutate();
drawable.setColor(color);
}
}
use of android.graphics.drawable.GradientDrawable in project BottomNavigation by Ashok-Varma.
the class TextBadgeItem method getBadgeDrawable.
/**
* @param context to fetch color
* @return return the background drawable
*/
private GradientDrawable getBadgeDrawable(Context context) {
GradientDrawable shape = new GradientDrawable();
shape.setShape(GradientDrawable.RECTANGLE);
shape.setCornerRadius(context.getResources().getDimensionPixelSize(R.dimen.badge_corner_radius));
shape.setColor(getBackgroundColor(context));
shape.setStroke(getBorderWidth(), getBorderColor(context));
return shape;
}
use of android.graphics.drawable.GradientDrawable in project MaterialAbout by jrvansuita.
the class AboutView method setDivider.
@SuppressWarnings("ResourceAsColor")
private void setDivider(AboutBuilder bundle, View holder) {
if (bundle.isShowDivider()) {
int color = bundle.getDividerColor();
if (color == 0)
color = isDarker() ? Color.GRAY : getNameColor();
GradientDrawable drawable = ((GradientDrawable) ((LayerDrawable) holder.getBackground()).findDrawableByLayerId(R.id.stroke));
if (drawable != null) {
drawable.setStroke(bundle.getDividerHeight(), color, bundle.getDividerDashWidth(), bundle.getDividerDashGap());
}
} else {
RippleUtil.background(holder, (Drawable) null);
}
}
use of android.graphics.drawable.GradientDrawable in project JustAndroid by chinaltz.
the class AbWheelView method initResourcesIfNecessary.
/**
* Initializes resources.
*/
private void initResourcesIfNecessary() {
if (itemsPaint == null) {
itemsPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
// itemsPaint.density = getResources().getDisplayMetrics().density;
itemsPaint.setTextSize(valueTextSize);
}
if (valuePaint == null) {
valuePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.FAKE_BOLD_TEXT_FLAG | Paint.DITHER_FLAG);
// valuePaint.density = getResources().getDisplayMetrics().density;
valuePaint.setTextSize(valueTextSize);
}
if (labelPaint == null) {
labelPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.FAKE_BOLD_TEXT_FLAG | Paint.DITHER_FLAG);
labelPaint.setTextSize(labelTextSize);
//设置阴影
labelPaint.setShadowLayer(0.5f, 0, 1, 0xFFFFFFFF);
}
//如果没设置中间的选中条用默认的颜色
if (centerSelectDrawable == null) {
GradientDrawable mGradientDrawable = new GradientDrawable(Orientation.BOTTOM_TOP, centerSelectGradientColors);
mGradientDrawable.setStroke(centerSelectStrokeWidth, centerSelectStrokeColor);
centerSelectDrawable = mGradientDrawable;
}
//上边界渐变层
if (topShadow == null) {
topShadow = new GradientDrawable(Orientation.TOP_BOTTOM, SHADOWS_COLORS);
}
//下边界渐变层
if (bottomShadow == null) {
bottomShadow = new GradientDrawable(Orientation.BOTTOM_TOP, SHADOWS_COLORS);
}
if (this.getBackground() == null) {
//原来用颜色渐变实现setBackgroundDrawable(layerDrawable);
//底部的颜色
GradientDrawable mGradientDrawable1 = new GradientDrawable(Orientation.TOP_BOTTOM, topGradientColors);
GradientDrawable mGradientDrawable2 = new GradientDrawable(Orientation.BOTTOM_TOP, bottomGradientColors);
mGradientDrawable1.setStroke(topStrokeWidth, topStrokeColor);
mGradientDrawable1.setShape(GradientDrawable.RECTANGLE);
mGradientDrawable2.setShape(GradientDrawable.RECTANGLE);
mGradientDrawable1.setGradientType(GradientDrawable.LINEAR_GRADIENT);
mGradientDrawable2.setGradientType(GradientDrawable.LINEAR_GRADIENT);
GradientDrawable[] mDrawables = new GradientDrawable[2];
mDrawables[0] = mGradientDrawable1;
mDrawables[1] = mGradientDrawable2;
LayerDrawable layerDrawable = new LayerDrawable(mDrawables);
//第一个参数0代表数组的第1个元素
layerDrawable.setLayerInset(0, 0, 0, 0, 0);
//第一个参数1代表数组的第2个元素
layerDrawable.setLayerInset(1, 4, 1, 4, 1);
setBackgroundDrawable(layerDrawable);
}
}
Aggregations