当前位置: 首页>>代码示例>>Java>>正文


Java Paint.setShadowLayer方法代码示例

本文整理汇总了Java中android.graphics.Paint.setShadowLayer方法的典型用法代码示例。如果您正苦于以下问题:Java Paint.setShadowLayer方法的具体用法?Java Paint.setShadowLayer怎么用?Java Paint.setShadowLayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Paint的用法示例。


在下文中一共展示了Paint.setShadowLayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createRoundIcon

import android.graphics.Paint; //导入方法依赖的package包/类
public static Bitmap createRoundIcon(Context context, Bitmap defaultIcon) {

        //calculate dimensions
        //-1 to take into account the shadow layer
        int w = defaultIcon.getWidth();
        int h = defaultIcon.getHeight();
        int r = w / 2 - 1;

        //create bitmap
        Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);

        //draw a circle of the same dimensions
        Canvas canvas = new Canvas(b);
        Paint paint = new Paint();
        paint.setColor(IconColorExtractor.get(context, defaultIcon));
        final int SHADOW_COLOR = 0x80000000;
        paint.setShadowLayer(0.5f, 1, 1, SHADOW_COLOR);
        paint.setAntiAlias(true);
        canvas.drawCircle(r, r, r, paint);

        //scale default icon and center inside the canvas
        Bitmap scaledBitmap = Bitmap.createScaledBitmap(defaultIcon, r, r, true);
        canvas.drawBitmap(scaledBitmap, (r * 2 - scaledBitmap.getWidth()) / 2, (r * 2 - scaledBitmap.getHeight()) / 2, paint);

        return b;
    }
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:27,代码来源:BoardUtils.java

示例2: drawBoxWithShadow

import android.graphics.Paint; //导入方法依赖的package包/类
private RectF drawBoxWithShadow(Canvas c, Paint p, int width, int height) {
    Resources res = mContext.getResources();
    float shadowBlur = res.getDimension(R.dimen.widget_preview_shadow_blur);
    float keyShadowDistance = res.getDimension(R.dimen.widget_preview_key_shadow_distance);
    float corner = res.getDimension(R.dimen.widget_preview_corner_radius);

    RectF bounds = new RectF(shadowBlur, shadowBlur,
            width - shadowBlur, height - shadowBlur - keyShadowDistance);
    p.setColor(Color.WHITE);

    // Key shadow
    p.setShadowLayer(shadowBlur, 0, keyShadowDistance,
            ShadowGenerator.KEY_SHADOW_ALPHA << 24);
    c.drawRoundRect(bounds, corner, corner, p);

    // Ambient shadow
    p.setShadowLayer(shadowBlur, 0, 0,
            ColorUtils.setAlphaComponent(Color.BLACK, ShadowGenerator.AMBIENT_SHADOW_ALPHA));
    c.drawRoundRect(bounds, corner, corner, p);

    p.clearShadowLayer();
    return bounds;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:24,代码来源:WidgetPreviewLoader.java

示例3: getShadowTextPaintByName

import android.graphics.Paint; //导入方法依赖的package包/类
static public Paint getShadowTextPaintByName(String name) {
	if (name == null) {
		return getDefShadowTextPaint();
	}
	TypefaceInfo typefaceInfo = _font_map.get(name);
	if (typefaceInfo == null) {
		return getDefShadowTextPaint();
	}
	Paint paint = typefaceInfo.paint;
	if (paint == null) {
		typefaceInfo.paint = paint = new Paint();
		paint.setTypeface(typefaceInfo.typeface);
		paint.setAntiAlias(true);
		paint.setSubpixelText(true);
		paint.setShadowLayer(3, 0, 0, Color.BLACK);
	}
	return paint;
}
 
开发者ID:starcor-company,项目名称:starcor.xul,代码行数:19,代码来源:XulRenderContext.java

示例4: setupInfoView

import android.graphics.Paint; //导入方法依赖的package包/类
private void setupInfoView() {

        outlinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        outlinePaint.setStyle(Paint.Style.STROKE);
        outlinePaint.setStrokeWidth(Util.dpToPixels(context, 1));
        outlinePaint.setColor(getRandomColor());

        basePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        basePaint.setStyle(Paint.Style.FILL);
        basePaint.setColor(Color.WHITE);
        basePaint.setShadowLayer(Util.dpToPixels(context, 1), 0, 0, Color.DKGRAY);
        setLayerType(LAYER_TYPE_SOFTWARE, basePaint);

        textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        textPaint.setTextSize(Util.dpToPixels(context, 6));
        textPaint.setColor(Color.BLACK);
        textPaint.setStyle(Paint.Style.FILL);

        gap = Util.dpToPixels(context, 2);
        radiusPixels = Util.dpToPixels(context, 2);
        textPadding = Util.dpToPixels(context, 2);
        textLinePadding = Util.dpToPixels(context, 1);

    }
 
开发者ID:adk96r,项目名称:Eye,代码行数:25,代码来源:PersonInfoView.java

示例5: createPaint

import android.graphics.Paint; //导入方法依赖的package包/类
/**
 * This method creates the instance of Paint.
 * In addition, this method sets styles for Paint.
 *
 * @return paint This is returned as the instance of Paint
 */
private Paint createPaint() {
  Paint paint = new Paint();

  paint.setAntiAlias(true);
  paint.setStyle(this.paintStyle);
  paint.setStrokeWidth(this.paintStrokeWidth);
  paint.setStrokeCap(this.lineCap);
  paint.setStrokeJoin(Paint.Join.MITER);  // fixed

  // for Text
  if (this.mode == Mode.TEXT) {
    paint.setTypeface(this.fontFamily);
    paint.setTextSize(this.fontSize);
    paint.setTextAlign(this.textAlign);
    paint.setStrokeWidth(0F);
  }

  if (this.mode == Mode.ERASER) {
    // Eraser
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    paint.setARGB(0, 0, 0, 0);

    // paint.setColor(this.baseColor);
    // paint.setShadowLayer(this.blur, 0F, 0F, this.baseColor);
  } else {
    // Otherwise
    paint.setColor(this.paintStrokeColor);
    paint.setShadowLayer(this.blur, 0F, 0F, this.paintStrokeColor);
    paint.setAlpha(this.opacity);
  }

  return paint;
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:40,代码来源:CanvasView.java

示例6: setUpPaint

import android.graphics.Paint; //导入方法依赖的package包/类
private void setUpPaint() {
        float density = getResources().getDisplayMetrics().density;
        mPaint = new Paint();
        mPaint.setColor(0xff2196F3);
        mPaint.setAntiAlias(true);
        mPaint.setStyle(Paint.Style.FILL);
        mPaint.setShadowLayer((int) (0.5f + 2.0f * density), 0f, 0f, SHADOW_COLOR);

//    float density = getResources().getDisplayMetrics().density;
//    mShadowPaint = new Paint();
//    mShadowPaint.setAntiAlias(true);
//    mShadowPaint.setShadowLayer((int) (0.5f + 2.0f * density), 0f, 0f, SHADOW_COLOR);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:WaveView.java

示例7: dispatchDraw

import android.graphics.Paint; //导入方法依赖的package包/类
@Override
protected void dispatchDraw(Canvas canvas) {

    if (mInvalidat) {

        mInvalidat = false;

        View view = getChildAt(0);

        Paint shadowPaint = new Paint();

        shadowPaint.setColor(Color.WHITE);
        shadowPaint.setStyle(Paint.Style.FILL);
        shadowPaint.setAntiAlias(true);

        int radius = view.getHeight() / 12 > 40 ? 40 : view.getHeight() / 12;
        int shadowDimen = view.getHeight() / 16 > 28 ? 28 : view.getHeight() / 16;

        Bitmap bitmap;
        int rgb;

        if (((ImageView) view).getDrawable() instanceof ColorDrawable) {
            rgb = ((ColorDrawable) ((ImageView) view).getDrawable()).getColor();
            shadowPaint.setShadowLayer(40, 0, 28, getDarkerColor(rgb));
        } else if (((ImageView) view).getDrawable() instanceof BitmapDrawable) {
            bitmap = ((BitmapDrawable) ((ImageView) view).getDrawable()).getBitmap();
            Palette.Swatch mSwatch = Palette.from(bitmap).generate().getDominantSwatch();

            if (null != mSwatch) {
                rgb = mSwatch.getRgb();
            } else {
                rgb = Color.parseColor("#8D8D8D");
            }

            shadowPaint.setShadowLayer(radius, 0, shadowDimen, getDarkerColor(rgb));
            Bitmap bitmapT = Bitmap.createBitmap(bitmap, 0, bitmap.getHeight() / 4 * 3,
                    bitmap.getWidth(), bitmap.getHeight() / 4);

            if (null != Palette.from(bitmapT).generate().getDominantSwatch()) {
                rgb = Palette.from(bitmapT).generate().getDominantSwatch().getRgb();
                shadowPaint.setShadowLayer(radius, 0, shadowDimen, rgb);
            }
        } else {
            rgb = Color.parseColor("#8D8D8D");
            shadowPaint.setShadowLayer(radius, 0, shadowDimen, getDarkerColor(rgb));
        }

        if (this.shadowColor != -147483648) {
            shadowPaint.setShadowLayer(radius, 0, shadowDimen, this.shadowColor);
        }

        RectF rectF = new RectF(view.getX() + (view.getWidth() / 20), view.getY(), view.getX() + view.getWidth() - (view.getWidth() / 20), view.getY() + view.getHeight() - ((view.getHeight() / 40)));

        canvas.drawRoundRect(rectF, shadowRound, shadowRound, shadowPaint);

        canvas.save();
    }
    super.dispatchDraw(canvas);
}
 
开发者ID:yingLanNull,项目名称:ShadowImageView,代码行数:60,代码来源:ShadowImageView.java

示例8: initPaint

import android.graphics.Paint; //导入方法依赖的package包/类
private void initPaint() {
  boardPaint = new Paint();
  boardPaint.setAntiAlias(true);
  boardPaint.setStyle(Paint.Style.FILL);
  boardPaint.setColor(Color.WHITE);
  boardPaint.setShadowLayer(5.0f, 0.0f, 2.0f, 0xFF000000);
}
 
开发者ID:saveendhiman,项目名称:FacebookReaction,代码行数:8,代码来源:RoundedBoard.java

示例9: initPaint

import android.graphics.Paint; //导入方法依赖的package包/类
private void initPaint() {
	//密码圆点画笔初始化
	pswDotPaint = new Paint();
	pswDotPaint.setAntiAlias(true);
	pswDotPaint.setStrokeWidth(3);
	pswDotPaint.setStyle(Paint.Style.FILL);
	pswDotPaint.setColor(pswColor);

	//明文密码画笔初始化
	pswTextPaint = new Paint();
	pswTextPaint.setAntiAlias(true);
	pswTextPaint.setFakeBoldText(true);
	pswTextPaint.setColor(pswColor);

	//边框画笔初始化
	borderPaint = new Paint();
	borderPaint.setAntiAlias(true);
	borderPaint.setColor(borderColor);
	borderPaint.setStyle(Paint.Style.STROKE);
	borderPaint.setStrokeWidth(3);

	//输入时边框画笔初始化
	inputBorderPaint = new Paint();
	inputBorderPaint.setAntiAlias(true);
	inputBorderPaint.setColor(inputBorderColor);
	inputBorderPaint.setStyle(Paint.Style.STROKE);
	inputBorderPaint.setStrokeWidth(3);
	//是否绘制边框阴影
	if (isShowBorderShadow) {
		inputBorderPaint.setShadowLayer(6, 0, 0, borderShadowColor);
		setLayerType(LAYER_TYPE_SOFTWARE, inputBorderPaint);
	}
}
 
开发者ID:rokudol,项目名称:PswText,代码行数:34,代码来源:PswText.java

示例10: drawBackground

import android.graphics.Paint; //导入方法依赖的package包/类
public void drawBackground(Canvas canvas, Paint paint) {
    canvas.save();
    canvas.translate(getOffsetX(), getOffsetY());

    paint.reset();
    if(Utilities.isAllowFolderTransparentPrefEnabled(Launcher.getLauncherActivity().getApplicationContext())){
        paint.setStyle(Paint.Style.STROKE);
    }else {
        paint.setStyle(Paint.Style.FILL);
    }
    paint.setXfermode(null);
    paint.setAntiAlias(true);

    int alpha = (int) Math.min(MAX_BG_OPACITY, BG_OPACITY * mColorMultiplier);
    if(Utilities.getFolderPreviewBackgroundPrefEnabled(Launcher.getLauncherActivity().getApplicationContext()) != -1){
        paint.setColor(Utilities.getFolderPreviewBackgroundPrefEnabled(Launcher.getLauncherActivity().getApplicationContext()));
    }else {
        paint.setColor(Color.argb(alpha, BG_INTENSITY, BG_INTENSITY, BG_INTENSITY));
    }
    float radius = getScaledRadius();

    canvas.drawCircle(radius, radius, radius, paint);
    canvas.clipPath(mClipPath, Region.Op.DIFFERENCE);

    paint.setStyle(Paint.Style.STROKE);
    paint.setColor(Color.TRANSPARENT);
    paint.setShadowLayer(mStrokeWidth, 0, mStrokeWidth, Color.argb(SHADOW_OPACITY, 0, 0, 0));
    canvas.drawCircle(radius, radius, radius, paint);

    canvas.restore();
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:32,代码来源:FolderIcon.java

示例11: createTextPaint

import android.graphics.Paint; //导入方法依赖的package包/类
private Paint createTextPaint(Resources resources) {
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(resources.getColor(R.color.ame_default_cluster_text_color));
    shadowBlurRadius = resources.getDimension(R.dimen.ame_default_cluster_text_shadow_blur_radius);
    if (shadowBlurRadius > 0.0f) {
        shadowOffsetX = resources.getDimension(R.dimen.ame_default_cluster_text_shadow_offset_x);
        shadowOffsetY = resources.getDimension(R.dimen.ame_default_cluster_text_shadow_offset_y);
        int shadowColor = resources.getColor(R.color.ame_default_cluster_text_shadow_color);
        paint.setShadowLayer(shadowBlurRadius, shadowOffsetX, shadowOffsetY, shadowColor);
    }
    paint.setTextSize(resources.getDimension(R.dimen.ame_default_cluster_text_size));
    paint.setTypeface(Typeface.DEFAULT_BOLD);
    return paint;
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:15,代码来源:DefaultClusterOptionsProvider.java

示例12: init

import android.graphics.Paint; //导入方法依赖的package包/类
private void init(Context context) {
    if (!this.isInEditMode()) {

        splats[0] = BitmapFactory.decodeResource(getResources(), R.drawable.splat1);
        splats[1] = BitmapFactory.decodeResource(getResources(), R.drawable.splat2);
        splats[2] = BitmapFactory.decodeResource(getResources(), R.drawable.splat2);
        anchor[0] = BitmapFactory.decodeResource(getResources(), R.drawable.anchor_sm);
        axes[0] = BitmapFactory.decodeResource(getResources(), R.drawable.axe2);
        bgs[0] = BitmapFactory.decodeResource(getResources(), R.drawable.sea);
        fgtops[0] = BitmapFactory.decodeResource(getResources(), R.drawable.sail);
        fgbottoms[0] = BitmapFactory.decodeResource(getResources(), R.drawable.shipside2);

        final SurfaceHolder holder = getHolder();
        holder.addCallback(this);
        TypedArray fish = getResources().obtainTypedArray(R.array.fish);
        int[] values = getResources().getIntArray(R.array.points);
        totalValue = 0;
        for (int i = 0; i < fish.length(); i++) {
            FlyingItem item = new FlyingItem(BitmapFactory.decodeResource(getResources(), fish.getResourceId(i, 0)));
            item.setValue(values[i]);
            availableItems.add(item);
            totalValue += (100 - values[i]);
        }
        fish.recycle();

        this.setOnTouchListener(this);
        mLinePaint = new Paint();
        mLinePaint.setARGB(255, 255, 64, 64);
        mLinePaint.setStrokeWidth(5);
        mBGPaint = new Paint();
        mBGPaint.setARGB(255, 127, 127, 200);

        mTextPaint = new Paint();
        mTextPaint.setColor(Color.BLACK);
        mTextPaint.setShadowLayer(8,8,8,Color.WHITE);
        mTextPaint.setTextSize(80);

    }
}
 
开发者ID:quaap,项目名称:SeafoodBerserker,代码行数:40,代码来源:MainFishView.java

示例13: setup

import android.graphics.Paint; //导入方法依赖的package包/类
private void setup() {

        mRectF = new RectF();
        mOuterRectF = new RectF();

        mOuterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mOuterPaint.setStrokeWidth(outLineWidth);
        mOuterPaint.setColor(mBackgroundColor);
        mOuterPaint.setStyle(Paint.Style.STROKE);

        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setStrokeWidth(lineWidth);
        mPaint.setColor(mBackgroundColor);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setPathEffect(new DashPathEffect(new float[]{dashWith, dashSpace}, dashSpace));

        mProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mProgressPaint.setStrokeWidth(lineWidth);
        mProgressPaint.setColor(mProgressColor);
        mProgressPaint.setStyle(Paint.Style.STROKE);
        mProgressPaint.setPathEffect(new DashPathEffect(new float[]{dashWith, dashSpace}, dashSpace));

        mPointerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPointerPaint.setStrokeWidth(pointLineWidth / 2);
        mPointerPaint.setColor(mProgressColor);
        mPointerPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPointerPaint.setStrokeCap(Paint.Cap.ROUND);
        mPointerPaint.setShadowLayer(4, 3, 0, 0x20000000);

        mInnerCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mInnerCirclePaint.setStrokeWidth(pointLineWidth);
        mInnerCirclePaint.setColor(mProgressColor);
        mInnerCirclePaint.setStyle(Paint.Style.STROKE);
        mInnerCirclePaint.setShadowLayer(4, 3, 0, 0x20000000);
    }
 
开发者ID:SailFlorve,项目名称:RunHDU,代码行数:36,代码来源:GradeProgressView.java

示例14: initView

import android.graphics.Paint; //导入方法依赖的package包/类
private void initView(Context context, AttributeSet attrs) {
    setMinimumHeight(DensityUtil.dp2px(100));

    mProgress = new MaterialProgressDrawable(context, this);
    mProgress.setBackgroundColor(CIRCLE_BG_LIGHT);
    mProgress.setAlpha(255);
    mProgress.setColorSchemeColors(0xff0099cc,0xffff4444,0xff669900,0xffaa66cc,0xffff8800);
    mCircleView = new CircleImageView(context,CIRCLE_BG_LIGHT);
    mCircleView.setImageDrawable(mProgress);
    mCircleView.setVisibility(View.GONE);
    addView(mCircleView);

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mCircleDiameter = (int) (CIRCLE_DIAMETER * metrics.density);

    mBezierPath = new Path();
    mBezierPaint = new Paint();
    mBezierPaint.setAntiAlias(true);
    mBezierPaint.setStyle(Paint.Style.FILL);

    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MaterialHeader);
    mShowBezierWave = ta.getBoolean(R.styleable.MaterialHeader_mhShowBezierWave, mShowBezierWave);
    mBezierPaint.setColor(ta.getColor(R.styleable.MaterialHeader_mhPrimaryColor, 0xff11bbff));
    if (ta.hasValue(R.styleable.MaterialHeader_mhShadowRadius)) {
        int radius = ta.getDimensionPixelOffset(R.styleable.MaterialHeader_mhShadowRadius, 0);
        int color = ta.getColor(R.styleable.MaterialHeader_mhShadowColor, 0xff000000);
        mBezierPaint.setShadowLayer(radius, 0, 0, color);
        setLayerType(LAYER_TYPE_SOFTWARE, null);
    }
    ta.recycle();

}
 
开发者ID:scwang90,项目名称:SmartRefreshLayout,代码行数:33,代码来源:MaterialHeader.java

示例15: drawLanguageOnSpacebar

import android.graphics.Paint; //导入方法依赖的package包/类
private void drawLanguageOnSpacebar(final Key key, final Canvas canvas, final Paint paint) {
    final Keyboard keyboard = getKeyboard();
    if (keyboard == null) {
        return;
    }
    final int width = key.getWidth();
    final int height = key.getHeight();
    paint.setTextAlign(Align.CENTER);
    paint.setTypeface(Typeface.DEFAULT);
    paint.setTextSize(mLanguageOnSpacebarTextSize);
    final String language = layoutLanguageOnSpacebar(paint, keyboard.mId.mSubtype, width);
    // Draw language text with shadow
    final float descent = paint.descent();
    final float textHeight = -paint.ascent() + descent;
    final float baseline = height / 2 + textHeight / 2;
    if (mLanguageOnSpacebarTextShadowRadius > 0.0f) {
        paint.setShadowLayer(mLanguageOnSpacebarTextShadowRadius, 0, 0,
                mLanguageOnSpacebarTextShadowColor);
    } else {
        paint.clearShadowLayer();
    }
    paint.setColor(mLanguageOnSpacebarTextColor);
    paint.setAlpha(mLanguageOnSpacebarAnimAlpha);
    canvas.drawText(language, width / 2, baseline - descent, paint);
    paint.clearShadowLayer();
    paint.setTextScaleX(1.0f);
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:28,代码来源:MainKeyboardView.java


注:本文中的android.graphics.Paint.setShadowLayer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。