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


Java ShapeDrawable.getPaint方法代碼示例

本文整理匯總了Java中android.graphics.drawable.ShapeDrawable.getPaint方法的典型用法代碼示例。如果您正苦於以下問題:Java ShapeDrawable.getPaint方法的具體用法?Java ShapeDrawable.getPaint怎麽用?Java ShapeDrawable.getPaint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.drawable.ShapeDrawable的用法示例。


在下文中一共展示了ShapeDrawable.getPaint方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addArrowView

import android.graphics.drawable.ShapeDrawable; //導入方法依賴的package包/類
/**
 * Adds an arrow view pointing at the original icon.
 * @param horizontalOffset the horizontal offset of the arrow, so that it
 *                              points at the center of the original icon
 */
private View addArrowView(int horizontalOffset, int verticalOffset, int width, int height) {
    LayoutParams layoutParams = new LayoutParams(width, height);
    if (mIsLeftAligned) {
        layoutParams.gravity = Gravity.START;
        layoutParams.leftMargin = horizontalOffset;
    } else {
        layoutParams.gravity = Gravity.END;
        layoutParams.rightMargin = horizontalOffset;
    }
    if (mIsAboveIcon) {
        layoutParams.topMargin = verticalOffset;
    } else {
        layoutParams.bottomMargin = verticalOffset;
    }

    View arrowView = new View(getContext());
    if (Gravity.isVertical(((FrameLayout.LayoutParams) getLayoutParams()).gravity)) {
        // This is only true if there wasn't room for the container next to the icon,
        // so we centered it instead. In that case we don't want to show the arrow.
        arrowView.setVisibility(INVISIBLE);
    } else {
        ShapeDrawable arrowDrawable = new ShapeDrawable(TriangleShape.create(
                width, height, !mIsAboveIcon));
        Paint arrowPaint = arrowDrawable.getPaint();
        // Note that we have to use getChildAt() instead of getItemViewAt(),
        // since the latter expects the arrow which hasn't been added yet.
        PopupItemView itemAttachedToArrow = (PopupItemView)
                (getChildAt(mIsAboveIcon ? getChildCount() - 1 : 0));
        arrowPaint.setColor(itemAttachedToArrow.getArrowColor(mIsAboveIcon));
        // The corner path effect won't be reflected in the shadow, but shouldn't be noticeable.
        int radius = getResources().getDimensionPixelSize(R.dimen.popup_arrow_corner_radius);
        arrowPaint.setPathEffect(new CornerPathEffect(radius));
        arrowView.setBackground(arrowDrawable);
        arrowView.setElevation(getElevation());
    }
    addView(arrowView, mIsAboveIcon ? getChildCount() : 0, layoutParams);
    return arrowView;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:44,代碼來源:PopupContainerWithArrow.java

示例2: createCircleDrawable

import android.graphics.drawable.ShapeDrawable; //導入方法依賴的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

示例3: createCircleDrawable

import android.graphics.drawable.ShapeDrawable; //導入方法依賴的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

示例4: StrengthMeter

import android.graphics.drawable.ShapeDrawable; //導入方法依賴的package包/類
public StrengthMeter(Context context, AttributeSet attrs) {
	super(context, attrs, android.R.attr.progressBarStyleHorizontal);
	bar = new ShapeDrawable();
	bar.getPaint().setColor(RED);
	ClipDrawable clip = new ClipDrawable(bar, LEFT, HORIZONTAL);
	ShapeDrawable background = new ShapeDrawable();
	Paint p = background.getPaint();
	p.setStyle(FILL);
	p.setColor(getResources().getColor(android.R.color.transparent));
	p.setStyle(STROKE);
	p.setStrokeWidth(1);
	p.setColor(BLACK);
	Drawable[] layers = new Drawable[] { clip, background };
	setProgressDrawable(new LayerDrawable(layers));
	setIndeterminate(false);
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:17,代碼來源:StrengthMeter.java

示例5: addBall

import android.graphics.drawable.ShapeDrawable; //導入方法依賴的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

示例6: initOverlay

import android.graphics.drawable.ShapeDrawable; //導入方法依賴的package包/類
private void initOverlay(Context context, Shape shape) {
    // pressed state
    TypedValue typedValue = new TypedValue();
    Theme theme = context.getTheme();

    mPressedOverlay = new ShapeDrawable(shape);
    int overlayColor = Color.parseColor("#aa888888");
    if (theme.resolveAttribute(R.attr.cp_badgeOverlayColor, typedValue, true)) {
        overlayColor = typedValue.data;
    }
    Paint paint = mPressedOverlay.getPaint();
    paint.setColor(overlayColor);
    paint.setStyle(Paint.Style.FILL);
    paint.setAntiAlias(true);
}
 
開發者ID:adithya321,項目名稱:SOS-The-Healthcare-Companion,代碼行數:16,代碼來源:ContactBadge.java

示例7: createOuterStrokeDrawable

import android.graphics.drawable.ShapeDrawable; //導入方法依賴的package包/類
private Drawable createOuterStrokeDrawable(float strokeWidth) {
  ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());

  final Paint paint = shapeDrawable.getPaint();
  paint.setAntiAlias(true);
  paint.setStrokeWidth(strokeWidth);
  paint.setStyle(Style.STROKE);
  paint.setColor(Color.BLACK);
  paint.setAlpha(opacityToAlpha(0.02f));

  return shapeDrawable;
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:13,代碼來源:FloatingActionButtonLibrary.java

示例8: createInnerStrokesDrawable

import android.graphics.drawable.ShapeDrawable; //導入方法依賴的package包/類
private Drawable createInnerStrokesDrawable(final int color, float strokeWidth) {
  if (!mStrokeVisible) {
    return new ColorDrawable(Color.TRANSPARENT);
  }

  ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());

  final int bottomStrokeColor = darkenColor(color);
  final int bottomStrokeColorHalfTransparent = halfTransparent(bottomStrokeColor);
  final int topStrokeColor = lightenColor(color);
  final int topStrokeColorHalfTransparent = halfTransparent(topStrokeColor);

  final Paint paint = shapeDrawable.getPaint();
  paint.setAntiAlias(true);
  paint.setStrokeWidth(strokeWidth);
  paint.setStyle(Style.STROKE);
  shapeDrawable.setShaderFactory(new ShaderFactory() {
    @Override
    public Shader resize(int width, int height) {
      return new LinearGradient(width / 2, 0, width / 2, height,
          new int[] { topStrokeColor, topStrokeColorHalfTransparent, color, bottomStrokeColorHalfTransparent, bottomStrokeColor },
          new float[] { 0f, 0.2f, 0.5f, 0.8f, 1f },
          TileMode.CLAMP
      );
    }
  });

  return shapeDrawable;
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:30,代碼來源:FloatingActionButtonLibrary.java

示例9: createOuterStrokeDrawable

import android.graphics.drawable.ShapeDrawable; //導入方法依賴的package包/類
private Drawable createOuterStrokeDrawable(float strokeWidth) {
        ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());

        final Paint paint = shapeDrawable.getPaint();
        paint.setAntiAlias(true);
        paint.setStrokeWidth(strokeWidth);
        paint.setStyle(Style.STROKE);
        paint.setColor(Color.BLACK);
        paint.setAlpha(opacityToAlpha(0.02f));

        return shapeDrawable;
}
 
開發者ID:HelloChenJinJun,項目名稱:TestChat,代碼行數:13,代碼來源:FloatingActionButton.java

示例10: createInnerStrokesDrawable

import android.graphics.drawable.ShapeDrawable; //導入方法依賴的package包/類
private Drawable createInnerStrokesDrawable(final int color, float strokeWidth) {
        if (!mStrokeVisible) {
                return new ColorDrawable(Color.TRANSPARENT);
        }

        ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());

        final int bottomStrokeColor = darkenColor(color);
        final int bottomStrokeColorHalfTransparent = halfTransparent(bottomStrokeColor);
        final int topStrokeColor = lightenColor(color);
        final int topStrokeColorHalfTransparent = halfTransparent(topStrokeColor);

        final Paint paint = shapeDrawable.getPaint();
        paint.setAntiAlias(true);
        paint.setStrokeWidth(strokeWidth);
        paint.setStyle(Style.STROKE);
        shapeDrawable.setShaderFactory(new ShaderFactory() {
                @Override
                public Shader resize(int width, int height) {
                        return new LinearGradient(width / 2, 0, width / 2, height,
                                new int[]{topStrokeColor, topStrokeColorHalfTransparent, color, bottomStrokeColorHalfTransparent, bottomStrokeColor},
                                new float[]{0f, 0.2f, 0.5f, 0.8f, 1f},
                                TileMode.CLAMP
                        );
                }
        });

        return shapeDrawable;
}
 
開發者ID:HelloChenJinJun,項目名稱:TestChat,代碼行數:30,代碼來源:FloatingActionButton.java

示例11: createFrameDrawableBg

import android.graphics.drawable.ShapeDrawable; //導入方法依賴的package包/類
/**
 * 創建 TextView 背景 {@link android.graphics.drawable.Drawable}
 *
 * @return {@link ShapeDrawable}
 */
private ShapeDrawable createFrameDrawableBg()
{
    ShapeDrawable shape = new ShapeDrawable(new RectShape());
    Paint paint = shape.getPaint();
    paint.setColor(frameColor);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(frameWidth);
    return shape;
}
 
開發者ID:Ayvytr,項目名稱:EasyAndroid,代碼行數:15,代碼來源:NewAuthEditText.java

示例12: initDefaultDrawable

import android.graphics.drawable.ShapeDrawable; //導入方法依賴的package包/類
/**
 * 初始化默認的Drawable,{@link #defaultDrawable}
 */
private void initDefaultDrawable()
{
    defaultDrawable = new ShapeDrawable(new RectShape());
    Paint paint = defaultDrawable.getPaint();
    paint.setColor(frameColor);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(strokeWidth);
    setTextViewDrawable(defaultDrawable);
}
 
開發者ID:Ayvytr,項目名稱:EasyAndroid,代碼行數:13,代碼來源:AuthEditText.java


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