Android仿qq未读消息_仿qq消息红点拖拽删除源代码
程序员文章站
2022-03-01 12:53:08
...
本Demo是一款仿qq未读消息、拖拽删除的例子、继承RelativeLayout的WaterDrop实现了圆形图标功能、继承ImageView的CircleImageView圆形图片功能、效果非常不错、很适合有圆形设计的哥们、效果图片如下
CircleImageView核心代码
private void updateShaderMatrix() { float scale; float dx = 0; float dy = 0; mShaderMatrix.set(null); if (mBitmapWidth * mDrawableRect.height() > mDrawableRect.width() * mBitmapHeight) { scale = mDrawableRect.height() / (float) mBitmapHeight; dx = (mDrawableRect.width() - mBitmapWidth * scale) * 0.5f; } else { scale = mDrawableRect.width() / (float) mBitmapWidth; dy = (mDrawableRect.height() - mBitmapHeight * scale) * 0.5f; } mShaderMatrix.setScale(scale, scale); mShaderMatrix.postTranslate((int) (dx 0.5f) mBorderWidth, (int) (dy 0.5f) mBorderWidth); mBitmapShader.setLocalMatrix(mShaderMatrix); }
WaterDrop核心代码
public boolean onTouchEvent(MotionEvent event) { ViewGroup parent = getScrollableParent(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mHolderEventFlag = !CoverManager.getInstance().isRunning(); if (mHolderEventFlag) { parent.requestDisallowInterceptTouchEvent(true); CoverManager.getInstance().start(this, event.getRawX(), event.getRawY(), mOnDragCompeteListener); } break; case MotionEvent.ACTION_MOVE: if (mHolderEventFlag) { CoverManager.getInstance().update(event.getRawX(), event.getRawY()); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: if (mHolderEventFlag) { parent.requestDisallowInterceptTouchEvent(false); CoverManager.getInstance().finish(this, event.getRawX(), event.getRawY()); } break; } return true; }
最后给贴上Demo的源代码、希望对大家有用、有兴趣的哥们可以下载看看
源代码下载链接: http://dwtedx.com/download.html?bdkey=s/1sjtDrhN 密码: ej8c