use of android.graphics.drawable.GradientDrawable in project wire-android by wireapp.
the class ColorUtils method getRoundedTextBoxBackground.
public static Drawable getRoundedTextBoxBackground(Context context, int color, int targetHeight) {
GradientDrawable drawable = new GradientDrawable();
color = injectAlpha(ROUNDED_TEXT_BOX_BACK_ALPHA, color);
drawable.setColor(color);
drawable.setCornerRadius(ViewUtils.toPx(context, targetHeight / 2));
return drawable;
}
use of android.graphics.drawable.GradientDrawable in project GridPasswordView by Jungerr.
the class GridPasswordView method generateBackgroundDrawable.
private GradientDrawable generateBackgroundDrawable() {
GradientDrawable drawable = new GradientDrawable();
drawable.setColor(mGridColor);
drawable.setStroke(mLineWidth, mLineColor);
return drawable;
}
use of android.graphics.drawable.GradientDrawable in project SuperToasts by JohnPersano.
the class SuperToast method onPrepareShow.
/**
* Modify various attributes of the SuperToast before being shown.
*/
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
protected void onPrepareShow() {
final int sdkVersion = android.os.Build.VERSION.SDK_INT;
// Modify various attributes of the message TextView
this.mTextView.setText(this.mStyle.message);
this.mTextView.setTypeface(this.mTextView.getTypeface(), this.mStyle.messageTypefaceStyle);
this.mTextView.setTextColor(this.mStyle.messageTextColor);
this.mTextView.setTextSize(this.mStyle.messageTextSize);
if (this.mStyle.messageIconResource > 0) {
if (this.mStyle.messageIconPosition == Style.ICONPOSITION_LEFT) {
this.mTextView.setCompoundDrawablesWithIntrinsicBounds(this.mStyle.messageIconResource, 0, 0, 0);
} else if (this.mStyle.messageIconPosition == Style.ICONPOSITION_TOP) {
this.mTextView.setCompoundDrawablesWithIntrinsicBounds(0, this.mStyle.messageIconResource, 0, 0);
} else if (this.mStyle.messageIconPosition == Style.ICONPOSITION_RIGHT) {
this.mTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, this.mStyle.messageIconResource, 0);
} else if (this.mStyle.messageIconPosition == Style.ICONPOSITION_BOTTOM) {
this.mTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, this.mStyle.messageIconResource);
}
}
// Handle depreciated API for setting the background
if (sdkVersion >= Build.VERSION_CODES.JELLY_BEAN) {
this.mView.setBackground(BackgroundUtils.getBackground(this.mStyle, this.mStyle.color));
// Give Lollipop devices a nice shadow (does not work with transparent backgrounds)
if (sdkVersion >= Build.VERSION_CODES.LOLLIPOP)
mView.setElevation(3f);
} else
this.mView.setBackgroundDrawable(BackgroundUtils.getBackground(this.mStyle, this.mStyle.color));
// Make adjustments that are specific to Lollipop frames
if (this.mStyle.frame == Style.FRAME_LOLLIPOP) {
this.mTextView.setGravity(Gravity.START);
// We are on a big screen device, show the SuperToast on the bottom left with padding
if ((this.mContext.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) {
this.mStyle.xOffset = BackgroundUtils.convertToDIP(12);
this.mStyle.yOffset = BackgroundUtils.convertToDIP(12);
this.mStyle.width = BackgroundUtils.convertToDIP(288);
this.mStyle.gravity = Gravity.BOTTOM | Gravity.START;
// Simple background shape with rounded corners
final GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setCornerRadius(BackgroundUtils.convertToDIP(2));
gradientDrawable.setColor(this.mStyle.color);
// Handle depreciated API for setting the background
if (sdkVersion >= Build.VERSION_CODES.JELLY_BEAN)
this.mView.setBackground(gradientDrawable);
else
this.mView.setBackgroundDrawable(gradientDrawable);
// We are NOT on a big screen device, show the SuperToast on the bottom with NO padding
} else {
this.mStyle.yOffset = 0;
this.mStyle.width = FrameLayout.LayoutParams.MATCH_PARENT;
}
// Set the priority color of the Lollipop frame if any
if (this.mStyle.priorityColor != 0) {
mView.findViewById(R.id.border).setVisibility(View.VISIBLE);
mView.findViewById(R.id.border).setBackgroundColor(this.mStyle.priorityColor);
}
}
// Used for PriorityQueue comparisons
this.getStyle().timestamp = System.currentTimeMillis();
}
use of android.graphics.drawable.GradientDrawable in project SuperToasts by JohnPersano.
the class BackgroundUtils method getKitkatBackground.
/**
* Private method.
*
* Returns a {@link GradientDrawable} with
* rounded corners.
*
* @param color The desired color of the GradientDrawable
* @return A {@link GradientDrawable}
*/
private static GradientDrawable getKitkatBackground(int color) {
final GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setCornerRadius(BackgroundUtils.convertToDIP(24));
gradientDrawable.setColor(color);
return gradientDrawable;
}
use of android.graphics.drawable.GradientDrawable in project BookReader by JustWayward.
the class PageWidget method drawCurrentBackArea.
@Override
protected void drawCurrentBackArea(Canvas canvas) {
int i = (int) (mBezierStart1.x + mBezierControl1.x) / 2;
float f1 = Math.abs(i - mBezierControl1.x);
int i1 = (int) (mBezierStart2.y + mBezierControl2.y) / 2;
float f2 = Math.abs(i1 - mBezierControl2.y);
float f3 = Math.min(f1, f2);
mPath1.reset();
mPath1.moveTo(mBeziervertex2.x, mBeziervertex2.y);
mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y);
mPath1.lineTo(mBezierEnd1.x, mBezierEnd1.y);
mPath1.lineTo(mTouch.x, mTouch.y);
mPath1.lineTo(mBezierEnd2.x, mBezierEnd2.y);
mPath1.close();
GradientDrawable mFolderShadowDrawable;
int left;
int right;
if (mIsRTandLB) {
left = (int) (mBezierStart1.x - 1);
right = (int) (mBezierStart1.x + f3 + 1);
mFolderShadowDrawable = mFolderShadowDrawableLR;
} else {
left = (int) (mBezierStart1.x - f3 - 1);
right = (int) (mBezierStart1.x + 1);
mFolderShadowDrawable = mFolderShadowDrawableRL;
}
canvas.save();
try {
canvas.clipPath(mPath0);
canvas.clipPath(mPath1, Region.Op.INTERSECT);
} catch (Exception e) {
}
mPaint.setColorFilter(mColorMatrixFilter);
float dis = (float) Math.hypot(mCornerX - mBezierControl1.x, mBezierControl2.y - mCornerY);
float f8 = (mCornerX - mBezierControl1.x) / dis;
float f9 = (mBezierControl2.y - mCornerY) / dis;
mMatrixArray[0] = 1 - 2 * f9 * f9;
mMatrixArray[1] = 2 * f8 * f9;
mMatrixArray[3] = mMatrixArray[1];
mMatrixArray[4] = 1 - 2 * f8 * f8;
mMatrix.reset();
mMatrix.setValues(mMatrixArray);
mMatrix.preTranslate(-mBezierControl1.x, -mBezierControl1.y);
mMatrix.postTranslate(mBezierControl1.x, mBezierControl1.y);
canvas.drawBitmap(mCurPageBitmap, mMatrix, mPaint);
// canvas.drawBitmap(bitmap, mMatrix, null);
mPaint.setColorFilter(null);
canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y);
mFolderShadowDrawable.setBounds(left, (int) mBezierStart1.y, right, (int) (mBezierStart1.y + mMaxLength));
mFolderShadowDrawable.draw(canvas);
canvas.restore();
}
Aggregations