當前位置: 首頁>>代碼示例>>Java>>正文


Java GradientDrawable.setStroke方法代碼示例

本文整理匯總了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) {

    }
}
 
開發者ID:w568w,項目名稱:fuckView,代碼行數:17,代碼來源:Hook.java

示例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);
}
 
開發者ID:maning0303,項目名稱:MNProgressHUD,代碼行數:18,代碼來源:MProgressDialog.java

示例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;
}
 
開發者ID:OmarAliSaid,項目名稱:android-paypal-example,代碼行數:25,代碼來源:BadgeDrawableBuilder.java

示例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);
}
 
開發者ID:jinseongho,項目名稱:lottie_for_designer,代碼行數:30,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:maning0303,項目名稱:MNProgressHUD,代碼行數:11,代碼來源:MStatusDialog.java

示例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);
}
 
開發者ID:alescdb,項目名稱:LauncherTV,代碼行數:10,代碼來源:ApplicationView.java

示例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();
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:10,代碼來源:IdentityView.java

示例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;
}
 
開發者ID:AstinPE,項目名稱:FloatingApps,代碼行數:14,代碼來源:FloatingButton.java

示例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;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:31,代碼來源:WeightDetailAdapter.java

示例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;
}
 
開發者ID:uccmawei,項目名稱:ColorView,代碼行數:30,代碼來源:ColorViewHelper.java

示例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;
}
 
開發者ID:sharewire,項目名稱:google-maps-clustering,代碼行數:10,代碼來源:DefaultIconGenerator.java

示例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()));


    }
 
開發者ID:Rishabhk07,項目名稱:Custom-Toggle-Button,代碼行數:47,代碼來源:CustomToggleButton.java

示例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;


}
 
開發者ID:Kaufland,項目名稱:andcoachmark,代碼行數:49,代碼來源:OkBelowDescriptionButtonRenderer.java

示例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);
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:6,代碼來源:MsgView.java

示例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));

}
 
開發者ID:maning0303,項目名稱:MNProgressHUD,代碼行數:45,代碼來源:MProgressBarDialog.java


注:本文中的android.graphics.drawable.GradientDrawable.setStroke方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。