本文整理汇总了Java中android.graphics.drawable.GradientDrawable.setStroke方法的典型用法代码示例。如果您正苦于以下问题:Java GradientDrawable.setStroke方法的具体用法?Java GradientDrawable.setStroke怎么用?Java GradientDrawable.setStroke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.drawable.GradientDrawable
的用法示例。
在下文中一共展示了GradientDrawable.setStroke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addViewShape
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private static void addViewShape(final View view) {
try {
GradientDrawable gd = new GradientDrawable();
gd.setStroke(4, Color.RED);
final Drawable background = view.getBackground();
view.setBackgroundDrawable(gd);
view.postDelayed(new Runnable() {
@Override
public void run() {
view.setBackgroundDrawable(background);
}
}, 800);
} catch (Throwable ignored) {
}
}
示例2: configView
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void configView() {
mDialog.setCanceledOnTouchOutside(mBuilder.canceledOnTouchOutside);
dialog_window_background.setBackgroundColor(mBuilder.backgroundWindowColor);
GradientDrawable myGrad = new GradientDrawable();
myGrad.setColor(mBuilder.backgroundViewColor);
myGrad.setStroke(MSizeUtils.dp2px(mContext, mBuilder.strokeWidth), mBuilder.strokeColor);
myGrad.setCornerRadius(MSizeUtils.dp2px(mContext, mBuilder.cornerRadius));
dialog_view_bg.setBackground(myGrad);
progress_wheel.setBarColor(mBuilder.progressColor);
progress_wheel.setBarWidth(MSizeUtils.dp2px(mContext, mBuilder.progressWidth));
progress_wheel.setRimColor(mBuilder.progressRimColor);
progress_wheel.setRimWidth(mBuilder.progressRimWidth);
tv_show.setTextColor(mBuilder.textColor);
}
示例3: build
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
public StateListDrawable build(Context ctx) {
StateListDrawable stateListDrawable = new StateListDrawable();
GradientDrawable normal = (GradientDrawable) ContextCompat.getDrawable(ctx, R.drawable.action_item_badge);
GradientDrawable selected = (GradientDrawable) normal.getConstantState().newDrawable().mutate();
normal.setColor(mColor);
selected.setColor(mColorPressed);
if (mStroke > -1) {
normal.setStroke(mStroke, mStrokeColor);
selected.setStroke(mStroke, mStrokeColor);
}
if (mCorners > -1) {
normal.setCornerRadius(mCorners);
selected.setCornerRadius(mCorners);
}
stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, selected);
stateListDrawable.addState(StateSet.WILD_CARD, normal);
return stateListDrawable;
}
示例4: onDrawTestButton
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void onDrawTestButton(int width, int height, float radius) {
mRlRoot2.removeAllViews();
mLlTestButtonControlLayout.setVisibility(View.VISIBLE);
RoundedCornerLayout buttonLView = new RoundedCornerLayout(this, radius);
RelativeLayout.LayoutParams buttonParams =
new RelativeLayout.LayoutParams(width, height);
buttonParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
buttonLView.setLayoutParams(buttonParams);
GradientDrawable gd = new GradientDrawable();
gd.setColor(Color.GRAY);
gd.setCornerRadius(10);
gd.setStroke(2, Color.WHITE);
buttonLView.setBackground(gd);
mAnimationView = new LottieAnimationView(MainActivity.this);
buttonLView.addView(mAnimationView);
mAnimationView.cancelAnimation();
buttonLView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mAnimationView.playAnimation();
mAnimationView.loop(false);
}
});
mButtonView = buttonLView;
onDrawTestButtonColor(buttonLView, "ff0000");
mRlRoot2.addView(buttonLView);
}
示例5: configView
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void configView() {
dialog_window_background.setBackgroundColor(mBuilder.backgroundWindowColor);
tvShow.setTextColor(mBuilder.textColor);
GradientDrawable myGrad = new GradientDrawable();
myGrad.setColor(mBuilder.backgroundViewColor);
myGrad.setStroke(MSizeUtils.dp2px(mContext, mBuilder.strokeWidth), mBuilder.strokeColor);
myGrad.setCornerRadius(MSizeUtils.dp2px(mContext, mBuilder.cornerRadius));
dialog_view_bg.setBackground(myGrad);
}
示例6: createTileShape
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private static Drawable createTileShape(int backgroundColor, int borderColor) {
GradientDrawable shape = new GradientDrawable();
shape.setShape(GradientDrawable.RECTANGLE);
shape.setCornerRadii(new float[]{7, 7, 7, 7, 0, 0, 0, 0});
shape.setColor(backgroundColor);
shape.setStroke(1, borderColor);
shape.setBounds(7, 7, 7, 7);
return (shape);
}
示例7: setColor
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
public void setColor(int color) {
mColor = color;
final GradientDrawable drawable = mDrawable;
if (drawable != null) {
drawable.setStroke(STROKE_SIZE, color);
}
setTextColor(color);
invalidate();
}
示例8: show
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
public Button show() {
final int DP = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, ctx.getResources().getDisplayMetrics());
GradientDrawable gradient = new GradientDrawable();
gradient.setCornerRadius(900 * DP);
gradient.setStroke(this.width, this.stroke_color);
gradient.setColor(this.color);
LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] { gradient, this.drawable });
layerDrawable.setLayerInset(1, padding[0], padding[1], padding[2], padding[3]);
this.fButton.setBackgroundDrawable(layerDrawable);
return this.fButton;
}
示例9: getView
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(this.context).inflate(R.layout.jm, parent, false);
}
final ScaleIndex itemData = (ScaleIndex) getItem(position);
TextView amount = (TextView) convertView.findViewById(R.id.tv_amount);
TextView level = (TextView) convertView.findViewById(R.id.tv_level);
((TextView) convertView.findViewById(R.id.tv_name)).setText(itemData.getName());
amount.setText(itemData.getValueWithUnit());
GradientDrawable drawable = new GradientDrawable();
drawable.setColor(ViewCompat.MEASURED_SIZE_MASK);
drawable.setCornerRadius(this.outerR[0]);
drawable.setStroke(1, itemData.getColor());
level.setBackgroundDrawable(drawable);
level.setTextColor(itemData.getColor());
level.setText(itemData.getLevelName());
if (itemData instanceof FakeIndex) {
convertView.setOnClickListener(null);
} else {
convertView.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
WeightDetailAdapter.this.mFragment.getDialog().getWindow()
.setWindowAnimations(R.style.df);
ScaleIndexActivity.startActivity(WeightDetailAdapter.this.context,
WeightDetailAdapter.this.mRecord, itemData.getName());
}
});
}
return convertView;
}
示例10: createDrawable
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private Drawable createDrawable(Drawable drawable, int backgroundColor, int borderColor, boolean forceToColorMode) {
if (!(drawable instanceof GradientDrawable) && !forceToColorMode) {
return drawable;
}
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setColor(backgroundColor);
gradientDrawable.setStroke(mBdWidth, borderColor, mBdDashWidth, mBdDashGap);
if (mCRTopLeft == mCRTopRight
&& mCRTopRight == mCRBottomRight
&& mCRBottomRight == mCRBottomLeft) {
gradientDrawable.setCornerRadius(mCRTopLeft);
} else {
float[] cornerArray = new float[8];
cornerArray[0] = mCRTopLeft;
cornerArray[1] = mCRTopLeft;
cornerArray[2] = mCRTopRight;
cornerArray[3] = mCRTopRight;
cornerArray[4] = mCRBottomRight;
cornerArray[5] = mCRBottomRight;
cornerArray[6] = mCRBottomLeft;
cornerArray[7] = mCRBottomLeft;
gradientDrawable.setCornerRadii(cornerArray);
}
return gradientDrawable;
}
示例11: createClusterBackground
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
@NonNull
private Drawable createClusterBackground() {
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setShape(GradientDrawable.OVAL);
gradientDrawable.setColor(mIconStyle.getClusterBackgroundColor());
gradientDrawable.setStroke(mIconStyle.getClusterStrokeWidth(),
mIconStyle.getClusterStrokeColor());
return gradientDrawable;
}
示例12: initialize
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
public void initialize(Context context, AttributeSet attrs) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
this.setBackground(getResources().getDrawable(R.drawable.toggle_background, null));
} else {
this.setBackground(getResources().getDrawable(R.drawable.toggle_background));
}
StateListDrawable stateListDrawable = (StateListDrawable) this.getBackground();
DrawableContainer.DrawableContainerState dcs = (DrawableContainer.DrawableContainerState) stateListDrawable.getConstantState();
Drawable[] drawableItems = dcs.getChildren();
GradientDrawable unChecked = (GradientDrawable) drawableItems[0];
GradientDrawable checked = (GradientDrawable) drawableItems[1];
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CustomToggleButton);
// getting all the attributes values set from the typed array i.e from user
int toggleOnColor = typedArray.getColor(R.styleable.CustomToggleButton_checkedColor, Color.parseColor("#FF4081"));
int toggleOffColor = typedArray.getColor(R.styleable.CustomToggleButton_uncheckedColor, Color.parseColor("#FF4081"));
float borderWidth = typedArray.getDimension(R.styleable.CustomToggleButton_borderWidth, 4.0f);
float radius = typedArray.getDimension(R.styleable.CustomToggleButton_radius, 15.0f);
int checkedTextColor = typedArray.getColor(R.styleable.CustomToggleButton_checkedTextColor, getResources().getColor(R.color.CheckedTextColor));
int uncheckedTextColor = typedArray.getColor(R.styleable.CustomToggleButton_uncheckedTextColor, getResources().getColor(R.color.uncheckedTextColor));
Log.d(TAG, "initialize: " + borderWidth);
ColorStateList colorStateList = new ColorStateList(
new int[][]{
new int[]{android.R.attr.state_checked},
new int[]{-android.R.attr.state_checked}
},
new int[]{
checkedTextColor,
uncheckedTextColor
}
);
this.setTextColor(colorStateList);
checked.setStroke(Math.round(borderWidth), toggleOnColor);
checked.setColor(toggleOnColor);
checked.setCornerRadius(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, radius, getResources().getDisplayMetrics()));
unChecked.setStroke(Math.round(borderWidth), toggleOffColor);
unChecked.setCornerRadius(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, radius, getResources().getDisplayMetrics()));
}
示例13: render
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
@Override
public View render(final CoachmarkViewLayout layout) {
if (inflated == null) {
LayoutInflater inflater = (LayoutInflater) layout.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflated = inflater.inflate(R.layout.ok_below_description_button_view, null);
layout.addView(inflated);
}
TextView mTxtOkBtn = (TextView) inflated.findViewById(R.id.txt_ok_btn);
LinearLayout mGroupOk = (LinearLayout) inflated.findViewById(R.id.group_ok);
mTxtOkBtn.setText(mOkText);
mGroupOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mListener == null || mListener.onClicked()) {
layout.dismiss();
}
}
});
if (mBorder != 0) {
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setStroke(mBorder, mColor != null ? mColor : ContextCompat.getColor(layout.getContext(),R.color.default_border_color));
mGroupOk.setBackground(gradientDrawable);
}
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
inflated.setLayoutParams(params);
inflated.post(new Runnable() {
@Override
public void run() {
RectF descriptionRectangle = layout.calcDescriptionRect();
inflated.setX(descriptionRectangle.centerX() - ((float) inflated.getWidth() / 2));
inflated.setY(descriptionRectangle.bottom + inflated.getContext().getResources().getDimension(R.dimen.button_padding));
inflated.setVisibility(View.VISIBLE);
}
});
return inflated;
}
示例14: setDrawable
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void setDrawable(GradientDrawable gd, int color, int strokeColor) {
gd.setColor(color);
gd.setCornerRadius(cornerRadius);
gd.setStroke(strokeWidth, strokeColor);
}
示例15: configView
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void configView() {
dialog_window_background.setBackgroundColor(mBuilder.backgroundWindowColor);
tvShow.setTextColor(mBuilder.textColor);
GradientDrawable myGrad = (GradientDrawable) dialog_view_bg.getBackground();
myGrad.setColor(mBuilder.backgroundViewColor);
myGrad.setStroke(MSizeUtils.dp2px(mContext, mBuilder.strokeWidth), mBuilder.strokeColor);
myGrad.setCornerRadius(MSizeUtils.dp2px(mContext, mBuilder.cornerRadius));
dialog_view_bg.setBackground(myGrad);
//horizontalProgressBar 配置
//背景
GradientDrawable progressBarBackgroundDrawable = new GradientDrawable();
progressBarBackgroundDrawable.setColor(mBuilder.progressbarBackgroundColor);
progressBarBackgroundDrawable.setCornerRadius(MSizeUtils.dp2px(mContext, mBuilder.progressCornerRadius));
//二级进度条
GradientDrawable secondProgressDrawable = new GradientDrawable();
secondProgressDrawable.setColor(mBuilder.progressbarBackgroundColor);
secondProgressDrawable.setCornerRadius(MSizeUtils.dp2px(mContext, mBuilder.progressCornerRadius));
ClipDrawable hProgressBar02 = new ClipDrawable(secondProgressDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
//一级进度条
GradientDrawable progressDrawable = new GradientDrawable();
progressDrawable.setColor(mBuilder.progressColor);
progressDrawable.setCornerRadius(MSizeUtils.dp2px(mContext, mBuilder.progressCornerRadius));
ClipDrawable hProgressBar03 = new ClipDrawable(progressDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
//组合
Drawable[] layers = {progressBarBackgroundDrawable, hProgressBar02, hProgressBar03};
LayerDrawable layerDrawable = new LayerDrawable(layers);
layerDrawable.setId(0, android.R.id.background);
layerDrawable.setId(1, android.R.id.secondaryProgress);
layerDrawable.setId(2, android.R.id.progress);
horizontalProgressBar.setProgressDrawable(layerDrawable);
ViewGroup.LayoutParams layoutParams = horizontalProgressBar.getLayoutParams();
layoutParams.height = MSizeUtils.dp2px(mContext, mBuilder.horizontalProgressBarHeight);
horizontalProgressBar.setLayoutParams(layoutParams);
//circularProgressBar 配置
circularProgressBar.setBackgroundColor(mBuilder.progressbarBackgroundColor);
circularProgressBar.setColor(mBuilder.progressColor);
circularProgressBar.setProgressBarWidth(MSizeUtils.dp2px(mContext, mBuilder.circleProgressBarWidth));
circularProgressBar.setBackgroundProgressBarWidth(MSizeUtils.dp2px(mContext, mBuilder.circleProgressBarBackgroundWidth));
}