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


Java RectShape類代碼示例

本文整理匯總了Java中android.graphics.drawable.shapes.RectShape的典型用法代碼示例。如果您正苦於以下問題:Java RectShape類的具體用法?Java RectShape怎麽用?Java RectShape使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: drawable

import android.graphics.drawable.shapes.RectShape; //導入依賴的package包/類
public static Drawable drawable(final int[] colorBoxes, final float[] position, final GradientAngle gradientAngle) {
    ShapeDrawable.ShaderFactory shaderFactory = new ShapeDrawable.ShaderFactory() {
        @Override
        public Shader resize(int width, int height) {
            AngleCoordinate ac = AngleCoordinate.getAngleCoordinate(gradientAngle, width, height);
            LinearGradient linearGradient = new LinearGradient(ac.x1, ac.y1, ac.x2, ac.y2,
                    colorBoxes,
                    position,
                    Shader.TileMode.REPEAT);
            return linearGradient;
        }
    };
    PaintDrawable paint = new PaintDrawable();
    paint.setShape(new RectShape());
    paint.setShaderFactory(shaderFactory);
    return paint;
}
 
開發者ID:akshay2211,項目名稱:Ariana,代碼行數:18,代碼來源:Ariana.java

示例2: setShape

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

示例3: setupColorImageView

import android.graphics.drawable.shapes.RectShape; //導入依賴的package包/類
void setupColorImageView(int[] padding, String type, int[] manualDimensions, boolean[] isManualDimensions, int[] autoDimensions) {
    colorImageView = new ImageView(gismoContext);
    fullContainerRelativeLayout.addView(colorImageView);
    colorImageView.setTag(Enums.ItemTag.Image);
    GradientDrawable outlineDrawable = new GradientDrawable();
    ShapeDrawable shapeDrawable = new ShapeDrawable();
    if (type.equals("oval")) {
        shapeDrawable.setShape(new OvalShape());
        outlineDrawable.setShape(GradientDrawable.OVAL);
    } else {
        shapeDrawable.setShape(new RectShape());
        outlineDrawable.setShape(GradientDrawable.RECTANGLE);
    }
    shapeDrawable.setIntrinsicWidth(isManualDimensions[0] ? manualDimensions[0] : autoDimensions[0]);
    shapeDrawable.setIntrinsicHeight(isManualDimensions[1] ? manualDimensions[1] : autoDimensions[1]);
    colorImageView.setImageDrawable(new LayerDrawable(new Drawable[]{shapeDrawable, outlineDrawable}));
    colorImageView.getLayoutParams().height = RelativeLayout.LayoutParams.WRAP_CONTENT;
    colorImageView.getLayoutParams().width = RelativeLayout.LayoutParams.WRAP_CONTENT;
    colorImageView.setPadding(padding[0], padding[1], padding[2], padding[3]);
    colorImageView.setAdjustViewBounds(true);
}
 
開發者ID:theawless,項目名稱:EventLock,代碼行數:22,代碼來源:EventViewBuilder.java

示例4: initBackgroundDrawable

import android.graphics.drawable.shapes.RectShape; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public Drawable initBackgroundDrawable(View view, Drawable mBackgroundColorDrawable) {
    RippleDrawable mBackgroundRippleDrawable = new RippleDrawable(
            ColorStateList.valueOf(Color.TRANSPARENT),
            null,
            new ShapeDrawable(new RectShape())
    );

    view.setBackground(new LayerDrawable(new Drawable[] {
            mBackgroundColorDrawable,
            mBackgroundRippleDrawable
    }));

    return mBackgroundRippleDrawable;
}
 
開發者ID:Defuera,項目名稱:justwidgets,代碼行數:17,代碼來源:RippleCompat.java

示例5: init

import android.graphics.drawable.shapes.RectShape; //導入依賴的package包/類
/**
 * Initializes the color seekbar with the gradient
 */
public void init() {
    LinearGradient colorGradient;
    if (Build.VERSION.SDK_INT >= 16) {
        colorGradient = new LinearGradient(0.f, 0.f, this.getMeasuredWidth() - this.getThumb().getIntrinsicWidth(), 0.f,
                new int[]{0xFF000000, 0xFF0000FF, 0xFF00FF00, 0xFF00FFFF,
                        0xFFFF0000, 0xFFFF00FF, 0xFFFFFF00, 0xFFFFFF},
                null, Shader.TileMode.CLAMP
        );
    } else {
        colorGradient = new LinearGradient(0.f, 0.f, this.getMeasuredWidth(), 0.f,
                new int[]{0xFF000000, 0xFF0000FF, 0xFF00FF00, 0xFF00FFFF,
                        0xFFFF0000, 0xFFFF00FF, 0xFFFFFF00, 0xFFFFFF},
                null, Shader.TileMode.CLAMP
        );
    }
    ShapeDrawable shape = new ShapeDrawable(new RectShape());
    shape.getPaint().setShader(colorGradient);
    this.setProgressDrawable(shape);
    this.setMax(256 * 7 - 1);
}
 
開發者ID:SwiftyWang,項目名稱:FingerColoring-Android,代碼行數:24,代碼來源:ColorPickerSeekBar.java

示例6: updateGradientParameters

import android.graphics.drawable.shapes.RectShape; //導入依賴的package包/類
/**
 * Update gradient parameters.
 */
private void updateGradientParameters() {
    // - Initialize gradient.
    mSideHypot = (int) Math.hypot(getWidth(), getHeight());
    ShapeDrawable mDrawable = new ShapeDrawable(new RectShape());
    final double radiansAngle = Math.toRadians(mDegreesAngle);
    mDrawable.getPaint().setShader(new LinearGradient(0, 0, (int) (mSideHypot * Math.cos(radiansAngle)), (int) (mSideHypot * Math.sin(radiansAngle)), mColorA, mColorB, Shader.TileMode.REPEAT));

    // - Initialize foreground gradient layout.
    if (mForegroundLayout == null) {
        mForegroundLayout = new FrameLayout(getContext());
        mForegroundLayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        addView(mForegroundLayout);
    }
    mForegroundLayout.setVisibility(isChecked() ? View.VISIBLE : View.INVISIBLE);
    mForegroundLayout.setForeground(mDrawable);
}
 
開發者ID:Jaouan,項目名稱:CompoundLayout,代碼行數:20,代碼來源:GradientRadioLayout.java

示例7: onLoaded

import android.graphics.drawable.shapes.RectShape; //導入依賴的package包/類
public final void onLoaded(FifeImageView paramFifeImageView, Bitmap paramBitmap)
{
  if (this.mSwatchView != null)
  {
    int i = Bitmap.createScaledBitmap(Bitmap.createBitmap(paramBitmap, 0, 0, paramBitmap.getWidth(), Math.min(20, paramBitmap.getHeight())), 1, 1, false).getPixel(0, 0);
    int j = Color.argb(0, Color.red(i), Color.green(i), Color.blue(i));
    float f = this.mTotalHeight;
    int[] arrayOfInt = { i, i, j };
    float[] arrayOfFloat = new float[3];
    arrayOfFloat[0] = 0.0F;
    arrayOfFloat[1] = this.mBreakPoint;
    arrayOfFloat[2] = 1.0F;
    LinearGradient localLinearGradient = new LinearGradient(0.0F, 0.0F, 0.0F, f, arrayOfInt, arrayOfFloat, Shader.TileMode.CLAMP);
    ShapeDrawable localShapeDrawable = new ShapeDrawable(new RectShape());
    localShapeDrawable.getPaint().setShader(localLinearGradient);
    UiUtils.setBackground(this.mSwatchView, localShapeDrawable);
    UiUtils.setBackground(this.mBackground, new ColorDrawable(i));
  }
  if (this.mOnLoadedListener != null) {
    this.mOnLoadedListener.onLoaded(paramFifeImageView, paramBitmap);
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:23,代碼來源:PlayHighlightsBannerItemView.java

示例8: kxi

import android.graphics.drawable.shapes.RectShape; //導入依賴的package包/類
public kxi(Context paramContext)
{
  mbb localmbb = mbb.b(paramContext);
  Resources localResources = paramContext.getResources();
  if (efj.D(paramContext)) {}
  for (Object localObject = new ColorDrawable(1342177280);; localObject = localResources.getDrawable(aau.BY))
  {
    this.e = new ShapeDrawable(new RectShape());
    this.e.getPaint().setColor(localResources.getColor(aau.BX));
    this.f = new ColorDrawable(this.e.getPaint().getColor());
    Drawable[] arrayOfDrawable = new Drawable[2];
    arrayOfDrawable[0] = localObject;
    arrayOfDrawable[1] = this.f;
    this.g = new LayerDrawable(arrayOfDrawable);
    this.c = efj.y(paramContext);
    this.h = ((kwz)localmbb.b(kwz.class));
    ((gpl)localmbb.a(gpl.class)).a(this);
    return;
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:21,代碼來源:kxi.java

示例9: getTransparentBitmap

import android.graphics.drawable.shapes.RectShape; //導入依賴的package包/類
public static Bitmap getTransparentBitmap(View parent) {

        //create a bitmap
        if (parent.getWidth() == 0 || parent.getHeight() == 0) {
            return null;
        }
        int width = parent.getWidth();
        int height = parent.getHeight();
        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);

        ShapeDrawable shapeDrawable = new ShapeDrawable(new RectShape());
        shapeDrawable.setAlpha(180);
        shapeDrawable.getPaint().setColor(0x66000000);
        shapeDrawable.setBounds(0, 0, width, height);
        shapeDrawable.draw(canvas);
        return bitmap;
    }
 
開發者ID:wingjay,項目名稱:jayAndroid,代碼行數:19,代碼來源:LayoutBlurActivity.java

示例10: init

import android.graphics.drawable.shapes.RectShape; //導入依賴的package包/類
private void init() {
    ShapeDrawable bottomLayer = new ShapeDrawable(new RectShape());
    bottomLayer.getPaint().setColor(Color.BLUE);

    ShapeDrawable midLayer = new ShapeDrawable(new RectShape());
    midLayer.getPaint().setColor(Color.GREEN);
    midLayer.getPaint().setStyle(Paint.Style.STROKE);//空心,only display the border line and transparent content

    Drawable[] layer = new Drawable[] {
            bottomLayer,
            midLayer,
            getContext().getResources().getDrawable(R.drawable.ic_fab_star)
    };
    LayerDrawable layerDrawable = new LayerDrawable(layer);
    // left, top, right, bottom. the distance with outer border of whole layout.
    layerDrawable.setLayerInset(0, 10, 10, 10, 10);
    layerDrawable.setLayerInset(1, 20, 20, 20, 20);

    setBackgroundByVersion(layerDrawable);
}
 
開發者ID:wingjay,項目名稱:jayAndroid,代碼行數:21,代碼來源:MyLayerDrawableView.java

示例11: ShapeDrawable

import android.graphics.drawable.shapes.RectShape; //導入依賴的package包/類
private static LayerDrawable ˊ(Context paramContext)
{
  int i = (int)(10.0F * paramContext.getResources().getDisplayMetrics().density);
  ShapeDrawable localShapeDrawable1 = new ShapeDrawable(new RectShape());
  Paint localPaint1 = localShapeDrawable1.getPaint();
  localPaint1.setColor(-1);
  localPaint1.setStyle(Paint.Style.FILL_AND_STROKE);
  localPaint1.setStrokeWidth(1.0F);
  localShapeDrawable1.setPadding(i, i, i, i);
  int j = (int)(1.5D * paramContext.getResources().getDisplayMetrics().density);
  ShapeDrawable localShapeDrawable2 = new ShapeDrawable(new RectShape());
  Paint localPaint2 = localShapeDrawable2.getPaint();
  localPaint2.setColor(-12303292);
  localPaint2.setStyle(Paint.Style.FILL_AND_STROKE);
  localPaint2.setStrokeWidth(1.0F);
  localShapeDrawable2.setPadding(0, 0, 0, j);
  return new LayerDrawable(new Drawable[] { localShapeDrawable2, localShapeDrawable1 });
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:19,代碼來源:FeedbackView.java

示例12: onSizeChanged

import android.graphics.drawable.shapes.RectShape; //導入依賴的package包/類
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);

    LinearGradient gradient =
            new LinearGradient(0.0f, 0.0f, ((float) getWidth()), 0.0f,
                    new int[]{0xFF000000, 0xFF0000FF, 0xFF00FF00, 0xFF00FFFF,
                            0xFFFF0000, 0xFFFF00FF, 0xFFFFFF00, 0xFFFFFFFF},
                    null, Shader.TileMode.CLAMP);
    ShapeDrawable shape = new ShapeDrawable(new RectShape());
    shape.getPaint().setShader(gradient);

    Rect bounds = getProgressDrawable().getBounds();
    setProgressDrawable(shape);
    getProgressDrawable().setBounds(bounds);
}
 
開發者ID:fuzz-productions,項目名稱:LimeLight,代碼行數:17,代碼來源:ColorHueSlider.java

示例13: init

import android.graphics.drawable.shapes.RectShape; //導入依賴的package包/類
public void init() {
  mPaint = new Paint();
  mPaint.setAlpha(100);
  setRippleColor(Color.BLACK, 0.2f);
  ShapeDrawable normal = new ShapeDrawable(new RectShape());
  normal.getPaint().setColor(Color.parseColor("#00FFFFFF"));
  StateListDrawable states = new StateListDrawable();

  states.addState(new int[] { android.R.attr.state_pressed, android.R.attr.state_enabled },
      normal);
  states.addState(new int[] { android.R.attr.state_focused, android.R.attr.state_enabled },
      normal);
  states.addState(new int[] { android.R.attr.state_enabled }, normal);
  states.addState(new int[] { -android.R.attr.state_enabled }, normal);
  setBackgroundDrawable(states);
}
 
開發者ID:yelinaung,項目名稱:OttoFit,代碼行數:17,代碼來源:RippleView.java

示例14: applyProgressBarSettings

import android.graphics.drawable.shapes.RectShape; //導入依賴的package包/類
private void applyProgressBarSettings() {
    if (mHeaderProgressBar != null) {
        final int strokeWidth = mHeaderProgressBar.getResources()
                .getDimensionPixelSize(R.dimen.ptr_progress_bar_stroke_width);

        mHeaderProgressBar.setIndeterminateDrawable(
                new SmoothProgressDrawable.Builder(mHeaderProgressBar.getContext())
                        .color(mProgressDrawableColor)
                        .strokeWidth(strokeWidth)
                        .build());

        ShapeDrawable shape = new ShapeDrawable();
        shape.setShape(new RectShape());
        shape.getPaint().setColor(mProgressDrawableColor);
        ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL);

        mHeaderProgressBar.setProgressDrawable(clipDrawable);
    }
}
 
開發者ID:Mobideck,項目名稱:appdeck-android,代碼行數:20,代碼來源:DefaultHeaderTransformer.java

示例15: applyProgressBarSettings

import android.graphics.drawable.shapes.RectShape; //導入依賴的package包/類
private void applyProgressBarSettings() {
    if (mHeaderProgressBar != null) {
        final int strokeWidth = mHeaderProgressBar.getResources()
                .getDimensionPixelSize(R.dimen.ptr_progress_bar_stroke_width);

        mHeaderProgressBar.setIndeterminateDrawable(
                new SmoothProgressDrawable.Builder(mHeaderProgressBar.getContext())
                        .color(mProgressDrawableColor)
                        .width(strokeWidth)
                        .build());

        ShapeDrawable shape = new ShapeDrawable();
        shape.setShape(new RectShape());
        shape.getPaint().setColor(mProgressDrawableColor);
        ClipDrawable clipDrawable = new ClipDrawable(shape, Gravity.CENTER, ClipDrawable.HORIZONTAL);

        mHeaderProgressBar.setProgressDrawable(clipDrawable);
    }
}
 
開發者ID:jonathangerbaud,項目名稱:Klyph,代碼行數:20,代碼來源:DefaultHeaderTransformer.java


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