use of android.graphics.drawable.GradientDrawable in project MyDiary by erttyy8821.
the class ThemeManager method createDiaryViewerInfoBg.
public Drawable createDiaryViewerInfoBg(Context context) {
int dp10 = ScreenHelper.dpToPixel(context.getResources(), 10);
GradientDrawable shape = new GradientDrawable();
shape.setShape(GradientDrawable.RECTANGLE);
shape.setColor(getThemeMainColor(context));
shape.setCornerRadii(new float[] { dp10, dp10, dp10, dp10, 0, 0, 0, 0 });
return shape;
}
use of android.graphics.drawable.GradientDrawable in project MyDiary by erttyy8821.
the class ThemeManager method createDiaryViewerEditBarBg.
public Drawable createDiaryViewerEditBarBg(Context context) {
int dp10 = ScreenHelper.dpToPixel(context.getResources(), 10);
GradientDrawable shape = new GradientDrawable();
shape.setShape(GradientDrawable.RECTANGLE);
shape.setColor(getThemeMainColor(context));
shape.setCornerRadii(new float[] { 0, 0, 0, 0, dp10, dp10, dp10, dp10 });
return shape;
}
use of android.graphics.drawable.GradientDrawable in project MyDiary by erttyy8821.
the class PageEffectView method drawNextPageAreaAndShadow.
private void drawNextPageAreaAndShadow(Canvas canvas, Bitmap bitmap) {
mPath1.reset();
mPath1.moveTo(mBezierStart1.x, mBezierStart1.y);
mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y);
mPath1.lineTo(mBeziervertex2.x, mBeziervertex2.y);
mPath1.lineTo(mBezierStart2.x, mBezierStart2.y);
mPath1.lineTo(mCornerX, mCornerY);
mPath1.close();
mDegrees = (float) Math.toDegrees(Math.atan2(mBezierControl1.x - mCornerX, mBezierControl2.y - mCornerY));
int leftx;
int rightx;
GradientDrawable mBackShadowDrawable;
if (mIsRTandLB) {
leftx = (int) (mBezierStart1.x);
rightx = (int) (mBezierStart1.x + mTouchToCornerDis / 4);
mBackShadowDrawable = mBackShadowDrawableLR;
} else {
leftx = (int) (mBezierStart1.x - mTouchToCornerDis / 4);
rightx = (int) mBezierStart1.x;
mBackShadowDrawable = mBackShadowDrawableRL;
}
canvas.save();
canvas.clipPath(mPath0);
canvas.clipPath(mPath1, Region.Op.INTERSECT);
canvas.drawBitmap(bitmap, 0, 0, null);
canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y);
mBackShadowDrawable.setBounds(leftx, (int) mBezierStart1.y, rightx, (int) (mMaxLength + mBezierStart1.y));
mBackShadowDrawable.draw(canvas);
canvas.restore();
}
use of android.graphics.drawable.GradientDrawable in project MyDiary by erttyy8821.
the class PageEffectView method drawCurrentBackArea.
/**
* Author : hmg25 Version: 1.0 Description : 绘制翻起页背面
*/
private void drawCurrentBackArea(Canvas canvas, Bitmap bitmap) {
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();
canvas.clipPath(mPath0);
canvas.clipPath(mPath1, Region.Op.INTERSECT);
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(bitmap, 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();
}
use of android.graphics.drawable.GradientDrawable in project cardslib by gabrielemariotti.
the class TopColoredCard method setupInnerViewElements.
@Override
public void setupInnerViewElements(ViewGroup parent, View view) {
//Use the title in super method
super.setupInnerViewElements(parent, view);
//Add a simple subtitle
if (view != null) {
ViewHolder holder = (ViewHolder) view.getTag();
if (holder == null) {
holder = new ViewHolder();
holder.mLinearLayoutContainer = (LinearLayout) view.findViewById(R.id.card_main_inner_topcolored_layout);
holder.mTitleView = (TextView) view.findViewById(R.id.card_main_inner_topcolored_title);
holder.mSubTitleView = (TextView) view.findViewById(R.id.card_main_inner_topcolored_subtitle);
View viewStub = ((View) getCardView()).findViewById(R.id.card_halfcolored_secondhalf);
if (viewStub != null) {
((ViewStub) viewStub).setLayoutResource(mSecondHalfViewStubLayoutId);
((ViewStub) viewStub).inflate();
holder.mSecondHalfView = ((View) getCardView()).findViewById(R.id.card_halfcolored_secondhalf_layout);
}
view.setTag(holder);
}
//Color the LinearLayout
if (holder.mLinearLayoutContainer != null && mColorResourceId != 0) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
holder.mLinearLayoutContainer.setBackgroundColor(mContext.getResources().getColor(mColorResourceId));
else {
((CardViewNative) (getCardView())).setPreventCornerOverlap(false);
GradientDrawable shapeDrawable = (GradientDrawable) (holder.mLinearLayoutContainer.getBackground());
shapeDrawable.setColor(mContext.getResources().getColor(mColorResourceId));
}
}
//Set the text elements
buildTitleOverColor(holder);
buildSubTitleOverColor(holder);
//Set the second half area
if (holder.mSecondHalfView != null && mSecondHalfViewStubLayoutId != 0) {
setupInnerViewElementsSecondHalf(holder.mSecondHalfView);
}
}
}
Aggregations