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


Java ShapeDrawable.setBounds方法代码示例

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


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

示例1: roundBitmap

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
public static Bitmap roundBitmap(Bitmap bitmap, int i, int i2, float f, float f2, float f3,
                                 float f4) throws Throwable {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    Rect rect = new Rect(0, 0, width, height);
    Bitmap createBitmap = (width == i && height == i2) ? Bitmap.createBitmap(bitmap.getWidth
            (), bitmap.getHeight(), Config.ARGB_8888) : Bitmap.createBitmap(i, i2, Config
            .ARGB_8888);
    Canvas canvas = new Canvas(createBitmap);
    Paint paint = new Paint();
    Rect rect2 = new Rect(0, 0, i, i2);
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(-12434878);
    float[] fArr = new float[]{f, f, f2, f2, f3, f3, f4, f4};
    ShapeDrawable shapeDrawable = new ShapeDrawable(new RoundRectShape(fArr, new RectF(0.0f,
            0.0f, 0.0f, 0.0f), fArr));
    shapeDrawable.setBounds(rect2);
    shapeDrawable.draw(canvas);
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect2, paint);
    return createBitmap;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:24,代码来源:BitmapHelper.java

示例2: MagnifierView

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
public MagnifierView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        bitmap = ((BitmapDrawable) getResources().getDrawable(R.drawable.pic)).getBitmap();
        scaledBitmap = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth() * FACTOR, bitmap.getHeight() * FACTOR,
                true);
//        bitmap.recycle();
        mBitmapShader = new BitmapShader(scaledBitmap,
                Shader.TileMode.CLAMP,
                Shader.TileMode.CLAMP);
        mShapeDrawable = new ShapeDrawable(new OvalShape());
        mShapeDrawable.setBounds(0, 0, WIDTH, WIDTH);
        mShapeDrawable.getPaint().setShader(mBitmapShader);
        mMatrix = new Matrix();
        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setColor(Color.RED);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeWidth(3);
    }
 
开发者ID:halohoop,项目名称:AndroidDigIn,代码行数:19,代码来源:MagnifierView.java

示例3: buildColorPickerView

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
private void buildColorPickerView(View view, int colorCode) {
    view.setVisibility(View.VISIBLE);

    ShapeDrawable biggerCircle = new ShapeDrawable(new OvalShape());
    biggerCircle.setIntrinsicHeight(20);
    biggerCircle.setIntrinsicWidth(20);
    biggerCircle.setBounds(new Rect(0, 0, 20, 20));
    biggerCircle.getPaint().setColor(colorCode);

    ShapeDrawable smallerCircle = new ShapeDrawable(new OvalShape());
    smallerCircle.setIntrinsicHeight(5);
    smallerCircle.setIntrinsicWidth(5);
    smallerCircle.setBounds(new Rect(0, 0, 5, 5));
    smallerCircle.getPaint().setColor(Color.WHITE);
    smallerCircle.setPadding(10, 10, 10, 10);
    Drawable[] drawables = {smallerCircle, biggerCircle};

    LayerDrawable layerDrawable = new LayerDrawable(drawables);

    view.setBackgroundDrawable(layerDrawable);
}
 
开发者ID:eventtus,项目名称:photo-editor-android,代码行数:22,代码来源:ColorPickerAdapter.java

示例4: Colorize

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void Colorize() {
    for (int i = 0; i < buttons.size(); i++) {
        ShapeDrawable d = new ShapeDrawable(new OvalShape());
        d.setBounds(58, 58, 58, 58);
        Log.e("Shape drown no", i + "");
        buttons.get(i).setVisibility(View.INVISIBLE);

            d.getPaint().setStyle(Paint.Style.FILL);
            d.getPaint().setColor(colors.get(i));

        buttons.get(i).setBackground(d);
    }
        animate();
}
 
开发者ID:delaroy,项目名称:MaterialColorPickerDialog,代码行数:16,代码来源:ColorChooserDialog.java

示例5: ColorizeOld

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
private void ColorizeOld() {
    for (int i = 0; i < buttons.size(); i++) {
        ShapeDrawable d = new ShapeDrawable(new OvalShape());
        d.getPaint().setColor(colors.get(i));
        d.getPaint().setStrokeWidth(1f);
        d.setBounds(58, 58, 58, 58);
        buttons.get(i).setVisibility(View.INVISIBLE);
            d.getPaint().setStyle(Paint.Style.FILL);
            d.getPaint().setColor(colors.get(i));
    buttons.get(i).setBackgroundDrawable(d);
    }
    animate();
}
 
开发者ID:delaroy,项目名称:MaterialColorPickerDialog,代码行数:14,代码来源:ColorChooserDialog.java

示例6: Oval

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
public Oval(float x,float y, float ray, int color, Context cont) {
    super(cont);
    this.x=x;
    this.y=y;
    this.ray=ray;

    int[] colors = {0xffffffff,color&0xddffffff,color};
    float[] stops = {0.9f, 0.95f,0.945f};
    mDrawable = new ShapeDrawable(new OvalShape());
    mDrawable.setBounds((int)(x-ray),(int)(y-ray),(int)(x+ray),(int)(y+ray));
    mDrawable.getPaint().setColor(color);
    mDrawable.getPaint().setShader(new RadialGradient(ray,ray,ray, colors, stops, Shader.TileMode.MIRROR ));

}
 
开发者ID:jkobject,项目名称:PiPle,代码行数:15,代码来源:Oval.java

示例7: studyBitmapShader

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
/**
     * 位图图像渲染
     * @param canvas
     */
    private void studyBitmapShader(Canvas canvas) {
        //创建BitmapShader
        //其中TileMode.MIRROR x方向镜像  TileMode.REPEAT y方向重复
        mBitmapShader = new BitmapShader(mBitMap, Shader.TileMode.MIRROR, Shader.TileMode.REPEAT);

        //创建矩阵   来缩放图片
        Matrix matrix = new Matrix();
        matrix.setScale(0.2f,0.2f);
        mBitmapShader.setLocalMatrix(matrix);

        mPaint.setAntiAlias(true);
        mPaint.setShader(mBitmapShader);

        //画圆形的图片
//        canvas.drawCircle(mBitMap.getWidth()/2,mBitMap.getHeight()/2,300,mPaint);

        //画矩形的图片
//        Rect rect = new Rect(0,0,600,600);
//        canvas.drawRect(rect,mPaint);
//
        //画椭圆的图片
//        RectF rectf = new RectF(0,0,400,300);
//
//        canvas.drawOval(rectf,mPaint);

        //用shapeDrawable 实现圆形图片
        ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());
        shapeDrawable.getPaint().setShader(mBitmapShader);
        shapeDrawable.setBounds(0,0,400,400);
        shapeDrawable.draw(canvas);

    }
 
开发者ID:fanxiaole,项目名称:androidShader_rippleView_radarView,代码行数:37,代码来源:MyGradientView.java

示例8: MyZoomImageView

import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
public MyZoomImageView(Context context) {
    super(context);

    mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.meinv);

    mBitmapScale = mBitmap;

    mBitmapScale = Bitmap.createScaledBitmap(mBitmapScale,mBitmap.getWidth() * FACTOR ,mBitmap.getHeight()*FACTOR,true);

    mBitmapShader = new BitmapShader(mBitmapScale, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);


    matrix = new Matrix();

    shapeDrawable = new ShapeDrawable(new OvalShape());
    shapeDrawable.getPaint().setShader(mBitmapShader);
    shapeDrawable.setBounds(0,0,RADIUS * 2,RADIUS * 2);


}
 
开发者ID:fanxiaole,项目名称:androidShader_rippleView_radarView,代码行数:21,代码来源:MyZoomImageView.java


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