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


Java OvalShape类代码示例

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


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

示例1: createCircleDrawable

import android.graphics.drawable.shapes.OvalShape; //导入依赖的package包/类
private Drawable createCircleDrawable(int color, float strokeWidth) {
  int alpha = Color.alpha(color);
  int opaqueColor = opaque(color);

  ShapeDrawable fillDrawable = new ShapeDrawable(new OvalShape());

  final Paint paint = fillDrawable.getPaint();
  paint.setAntiAlias(true);
  paint.setColor(opaqueColor);

  Drawable[] layers = {
      fillDrawable,
      createInnerStrokesDrawable(opaqueColor, strokeWidth)
  };

  LayerDrawable drawable = alpha == 255 || !mStrokeVisible
      ? new LayerDrawable(layers)
      : new TranslucentLayerDrawable(alpha, layers);

  int halfStrokeWidth = (int) (strokeWidth / 2f);
  drawable.setLayerInset(1, halfStrokeWidth, halfStrokeWidth, halfStrokeWidth, halfStrokeWidth);

  return drawable;
}
 
开发者ID:nhocga1995s,项目名称:MyCalendar,代码行数:25,代码来源:FloatingActionButtonLibrary.java

示例2: createCircleDrawable

import android.graphics.drawable.shapes.OvalShape; //导入依赖的package包/类
private Drawable createCircleDrawable(int color, float strokeWidth) {
        int alpha = Color.alpha(color);
        int opaqueColor = opaque(color);

        ShapeDrawable fillDrawable = new ShapeDrawable(new OvalShape());

        final Paint paint = fillDrawable.getPaint();
        paint.setAntiAlias(true);
        paint.setColor(opaqueColor);

        Drawable[] layers = {
                fillDrawable,
                createInnerStrokesDrawable(opaqueColor, strokeWidth)
        };

        LayerDrawable drawable = alpha == 255 || !mStrokeVisible
                ? new LayerDrawable(layers)
                : new TranslucentLayerDrawable(alpha, layers);

        int halfStrokeWidth = (int) (strokeWidth / 2f);
        drawable.setLayerInset(1, halfStrokeWidth, halfStrokeWidth, halfStrokeWidth, halfStrokeWidth);

        return drawable;
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:25,代码来源:FloatingActionButton.java

示例3: createProductImageDrawable

import android.graphics.drawable.shapes.OvalShape; //导入依赖的package包/类
private Drawable createProductImageDrawable(Product product) {
    final ShapeDrawable background = new ShapeDrawable();
    background.setShape(new OvalShape());
    background.getPaint().setColor(ContextCompat.getColor(getContext(), product.color));

    final BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(),
            BitmapFactory.decodeResource(getResources(), product.image));

    final LayerDrawable layerDrawable = new LayerDrawable
            (new Drawable[]{background, bitmapDrawable});

    final int padding = (int) getResources().getDimension(R.dimen.spacing_huge);
    layerDrawable.setLayerInset(1, padding, padding, padding, padding);

    return layerDrawable;
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:17,代码来源:OrderDialogFragment.java

示例4: createShadowShapeDrawable

import android.graphics.drawable.shapes.OvalShape; //导入依赖的package包/类
@Override
public Drawable createShadowShapeDrawable(Context context, final CircleLoadingView circleLoadingView, int shadowColor) {
    final float density = context.getResources().getDisplayMetrics().density;
    ShapeDrawable circle = new ShapeDrawable(new OvalShape());
    circle.getPaint().setColor(shadowColor);
    final float elevation = SHADOW_ELEVATION * density;
    circleLoadingView.setElevation(elevation);

    circleLoadingView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            ViewParent p = circleLoadingView.getParent();
            if(p instanceof ViewGroup) {
                final int margin = (int) elevation;
                ViewGroup.LayoutParams params = circleLoadingView.getLayoutParams();
                if(params instanceof ViewGroup.MarginLayoutParams){
                    ((ViewGroup.MarginLayoutParams) params).setMargins(margin, margin, margin, margin);
                }
            }

            circleLoadingView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }
    });

    return circle;
}
 
开发者ID:lliuguangbo,项目名称:circleloadingview,代码行数:27,代码来源:CircleLoadingView.java

示例5: MagnifierView

import android.graphics.drawable.shapes.OvalShape; //导入依赖的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

示例6: getLargeNotificationIcon

import android.graphics.drawable.shapes.OvalShape; //导入依赖的package包/类
private Bitmap getLargeNotificationIcon(Bitmap bitmap) {
    Resources resources = mContext.getResources();
    int height = (int) resources.getDimension(android.R.dimen.notification_large_icon_height);
    int width = (int) resources.getDimension(android.R.dimen.notification_large_icon_width);
    final OvalShape circle = new OvalShape();
    circle.resize(width, height);
    final Paint paint = new Paint();
    paint.setColor(ApiCompatibilityUtils.getColor(resources, R.color.google_blue_grey_500));

    final Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(result);
    circle.draw(canvas, paint);
    float leftOffset = (width - bitmap.getWidth()) / 2f;
    float topOffset = (height - bitmap.getHeight()) / 2f;
    if (leftOffset >= 0 && topOffset >= 0) {
        canvas.drawBitmap(bitmap, leftOffset, topOffset, null);
    } else {
        // Scale down the icon into the notification icon dimensions
        canvas.drawBitmap(bitmap,
                new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()),
                new Rect(0, 0, width, height),
                null);
    }
    return result;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:26,代码来源:DownloadNotificationService.java

示例7: getCircleIcon

import android.graphics.drawable.shapes.OvalShape; //导入依赖的package包/类
private static Bitmap getCircleIcon(
        Context context, @ColorInt int backgroundColor, int backgroundInset,
        @DrawableRes int iconResId, @ColorInt int iconColor, int iconInset) {
    Drawable[] layers = new Drawable[2];
    ShapeDrawable background = new ShapeDrawable(new OvalShape());
    background.getPaint().setColor(backgroundColor);
    Drawable icon = ContextCompat.getDrawable(context, iconResId);
    Drawable tintedIcon = DrawableCompat.wrap(icon.mutate());
    DrawableCompat.setTint(tintedIcon, iconColor);
    layers[0] = background;
    layers[1] = tintedIcon;
    LayerDrawable layerDrawable = new LayerDrawable(layers);
    layerDrawable.setLayerInset(1, iconInset, iconInset, iconInset, iconInset);
    layerDrawable.setLayerInset(0, backgroundInset, backgroundInset, backgroundInset, backgroundInset);
    return drawableToBitmap(layerDrawable);
}
 
开发者ID:nicholasrout,项目名称:shortstories,代码行数:17,代码来源:BitmapUtil.java

示例8: buildColorPickerView

import android.graphics.drawable.shapes.OvalShape; //导入依赖的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

示例9: addBall

import android.graphics.drawable.shapes.OvalShape; //导入依赖的package包/类
private ShapeHolder addBall(float x, float y) {
    OvalShape circle = new OvalShape();
    circle.resize(50f, 50f);
    ShapeDrawable drawable = new ShapeDrawable(circle);
    ShapeHolder shapeHolder = new ShapeHolder(drawable);
    shapeHolder.setX(x - 25f);
    shapeHolder.setY(y - 25f);
    int red = (int)(Math.random() * 255);
    int green = (int)(Math.random() * 255);
    int blue = (int)(Math.random() * 255);
    int color = 0xff000000 | red << 16 | green << 8 | blue;
    Paint paint = drawable.getPaint(); //new Paint(Paint.ANTI_ALIAS_FLAG);
    int darkColor = 0xff000000 | red/4 << 16 | green/4 << 8 | blue/4;
    RadialGradient gradient = new RadialGradient(37.5f, 12.5f,
            50f, color, darkColor, Shader.TileMode.CLAMP);
    paint.setShader(gradient);
    shapeHolder.setPaint(paint);
    balls.add(shapeHolder);
    return shapeHolder;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:21,代码来源:BouncingBalls.java

示例10: createProductImageDrawable

import android.graphics.drawable.shapes.OvalShape; //导入依赖的package包/类
private Drawable createProductImageDrawable(Product product) {
    final ShapeDrawable background = new ShapeDrawable();
    background.setShape(new OvalShape());
    background.getPaint().setColor(ContextCompat.getColor(getContext(), product.color));

    final BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(),
        BitmapFactory.decodeResource(getResources(), product.image));

    final LayerDrawable layerDrawable = new LayerDrawable
        (new Drawable[]{background, bitmapDrawable});

    final int padding = (int) getResources().getDimension(R.dimen.spacing_huge);
    layerDrawable.setLayerInset(1, padding, padding, padding, padding);

    return layerDrawable;
}
 
开发者ID:saulmm,项目名称:From-design-to-Android-part1,代码行数:17,代码来源:OrderDialogFragment.java

示例11: select

import android.graphics.drawable.shapes.OvalShape; //导入依赖的package包/类
public void select(int dayOfOrder) {
    this.selected = dayOfOrder;
    resetSelect();
    if (this.mSelectListener != null) {
        this.mSelectListener.onSelect(dayOfOrder);
    }
    TextView tv = (TextView) this.tvList.get(dayOfOrder);
    tv.setTextColor(getResources().getColor(R.color.ju));
    ShapeDrawable oval = new ShapeDrawable(new OvalShape());
    if (dayOfOrder == this.orderOfToday) {
        oval.getPaint().setColor(getResources().getColor(R.color.he));
    } else {
        oval.getPaint().setColor(getResources().getColor(R.color.hb));
    }
    tv.setBackgroundDrawable(oval);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:WeekView.java

示例12: setShape

import android.graphics.drawable.shapes.OvalShape; //导入依赖的package包/类
private void setShape() {
  ShapeDrawable drawable = new ShapeDrawable();
  // Set color of drawable.
  drawable.getPaint().setColor((backgroundColor == Component.COLOR_DEFAULT)
                               ? SHAPED_DEFAULT_BACKGROUND_COLOR : backgroundColor);
  // Set shape of drawable.
  switch (shape) {
    case Component.BUTTON_SHAPE_ROUNDED:
      drawable.setShape(new RoundRectShape(ROUNDED_CORNERS_ARRAY, null, null));
      break;
    case Component.BUTTON_SHAPE_RECT:
      drawable.setShape(new RectShape());
      break;
    case Component.BUTTON_SHAPE_OVAL:
      drawable.setShape(new OvalShape());
      break;
    default:
      throw new IllegalArgumentException();
  }
  // Set drawable to the background of the button.
  view.setBackgroundDrawable(drawable);
  view.invalidate();
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:24,代码来源:ButtonBase.java

示例13: CircleImageView

import android.graphics.drawable.shapes.OvalShape; //导入依赖的package包/类
public CircleImageView(Context context, int color, final float radius) {
    super(context);
    final float density = getContext().getResources().getDisplayMetrics().density;
    final int diameter = (int) (radius * density * 2);
    final int shadowYOffset = (int) (density * Y_OFFSET);
    final int shadowXOffset = (int) (density * X_OFFSET);

    mShadowRadius = (int) (density * SHADOW_RADIUS);

    ShapeDrawable circle;
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {
        OvalShape oval = new OvalShadow(mShadowRadius, diameter);
        circle = new ShapeDrawable(oval);
        ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, circle.getPaint());
        circle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset,
                KEY_SHADOW_COLOR);
        final int padding = mShadowRadius;
        // set padding so the inner image sits correctly within the shadow.
        setPadding(padding, padding, padding, padding);
    }
    circle.getPaint().setColor(color);
    setBackgroundDrawable(circle);
}
 
开发者ID:DIY-green,项目名称:AndroidStudyDemo,代码行数:27,代码来源:CircleImageView.java

示例14: CircleImageViewSupport

import android.graphics.drawable.shapes.OvalShape; //导入依赖的package包/类
public CircleImageViewSupport(Context context, int color, final float radius) {
    super(context);
    final float density = getContext().getResources().getDisplayMetrics().density;
    final int diameter = (int) (radius * density * 2);
    final int shadowYOffset = (int) (density * Y_OFFSET);
    final int shadowXOffset = (int) (density * X_OFFSET);

    mShadowRadius = (int) (density * SHADOW_RADIUS);

    ShapeDrawable circle;
    if (elevationSupported()) {
        circle = new ShapeDrawable(new OvalShape());
        ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {
        OvalShape oval = new OvalShadow(mShadowRadius, diameter);
        circle = new ShapeDrawable(oval);
        ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, circle.getPaint());
        circle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset,
                KEY_SHADOW_COLOR);
        final int padding = mShadowRadius;
        // set padding so the inner image sits correctly within the shadow.
        setPadding(padding, padding, padding, padding);
    }
    circle.getPaint().setColor(color);
    setBackgroundDrawable(circle);
}
 
开发者ID:LegendKe,项目名称:MyTravelingDiary,代码行数:27,代码来源:CircleImageViewSupport.java

示例15: init

import android.graphics.drawable.shapes.OvalShape; //导入依赖的package包/类
private void init(AttributeSet attrs, int defStyle) {
    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(
            attrs, R.styleable.LevelView, defStyle, 0);

    mBackground = new ShapeDrawable(new OvalShape());
    mBackground.getPaint().setColor(getResources().getColor(R.color.level_background_color));
    mBubble = new ShapeDrawable(new OvalShape());
    mBubble.getPaint().setColor(getResources().getColor(R.color.level_bubble_color));

    mMarkPaint = new Paint();
    mMarkPaint.setColor(getResources().getColor(R.color.level_mark_color));

    mEdgePaint = new Paint();
    mEdgePaint.setColor(getResources().getColor((R.color.level_edge_color)));
    mEdgePaint.setStyle(Paint.Style.STROKE);
    mEdgePaint.setStrokeWidth(a.getDimension(R.styleable.LevelView_edgeWidth, 10));

    a.recycle();
}
 
开发者ID:google,项目名称:science-journal,代码行数:21,代码来源:LevelView.java


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