本文整理汇总了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;
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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);
}
示例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 });
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}