vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/graphics/GradientView.java
private boolean mShowScrim = true;
protected void onDraw(Canvas canvas) {
Paint paint = mShowScrim ? mPaintWithScrim : mPaintNoScrim;
float head = 0.29f;
float linearProgress = head + (mProgress * (1f - head));
float startMaskY = (1f - linearProgress) * mHeight - mMaskHeight * linearProgress;
float interpolatedAlpha = (255 - mAlphaStart) * mAccelerator.getInterpolation(mProgress);
paint.setAlpha((int) (mAlphaStart + interpolatedAlpha));
float div = (float) Math.floor(startMaskY + mMaskHeight);
mAlphaMaskRect.set(0, startMaskY, mWidth, div);
mFinalMaskRect.set(0, div, mWidth, mHeight);
- canvas.drawBitmap(mAlphaGradientMask, null, mAlphaMaskRect, paint);
+ // canvas.drawBitmap(mAlphaGradientMask, null, mAlphaMaskRect, paint); //huacao
canvas.drawRect(mFinalMaskRect, paint);
问题:修改后底下出现其他颜色的部分!
原因:机器本来是800*1280的,结果dpi设置为160,导致了这个问题。
解决方法一: 改dpi 为213或者240
解决方法二 :把mMaskHeight 加点值 ,比如,mMaskHeight 改为 (mMaskHeight+30) 。
vendor/mediatek/proprietary/packages/apps/Launcher3/src/com/android/launcher3/graphics/GradientView.java
@Override
protected void onDraw(Canvas canvas) {
Paint paint = mShowScrim ? mPaintWithScrim : mPaintNoScrim;
Paint paint1 = mPaintNoScrim; //huacao
float head = 0.29f;
float linearProgress = head + (mProgress * (1f - head));
float startMaskY = (1f - linearProgress) * mHeight - (mMaskHeight+30) * linearProgress; //huacao
float interpolatedAlpha = (255 - mAlphaStart) * mAccelerator.getInterpolation(mProgress);
paint.setAlpha((int) (mAlphaStart + interpolatedAlpha));
float div = (float) Math.floor(startMaskY + (mMaskHeight+30));//huacao
mAlphaMaskRect.set(0, startMaskY, mWidth, div);
mFinalMaskRect.set(0, div, mWidth, mHeight);
//canvas.drawBitmap(mAlphaGradientMask, null, mAlphaMaskRect, paint);//huacao
canvas.drawRect(mFinalMaskRect, paint);
if (DEBUG) {
mDebugPaint.setColor(0xFF00FF00);
canvas.drawLine(0, startMaskY, mWidth, startMaskY, mDebugPaint);
canvas.drawLine(0, startMaskY + (mMaskHeight), mWidth, startMaskY + (mMaskHeight), mDebugPaint);
}
}