android 给图片蒙上蒙层

编程入门 行业动态 更新时间:2024-10-26 06:27:05

android 给<a href=https://www.elefans.com/category/jswz/34/1770705.html style=图片蒙上蒙层"/>

android 给图片蒙上蒙层

蒙层是什么,蒙层是一层透明的呈灰色的视图,是在用户使用App时让用户快速学会使用的一些指导。类似于一些引导页面,只不过比引导页面更加生动形象而已。在GitHub上有具体的demo。

地址为   github源码地址,需要的可以去上面下载源码看看

使用引导蒙层非常简单,只要在你的项目中导入一个GuideView类即可,当然,别忘了在values的资源文件下加上相应的一些数值。

下面是GuideView的原码

public class GuideView extends RelativeLayout implements ViewTreeObserver.OnGlobalLayoutListener {

private final String TAG = getClass().getSimpleName();

private Context mContent;

private List mViews;

private boolean first = true;

/**

* targetView前缀。SHOW_GUIDE_PREFIX + targetView.getId()作为保存在SP文件的key。

*/

private static final String SHOW_GUIDE_PREFIX = "show_guide_on_view_";

/**

* GuideView 偏移量

*/

private int offsetX, offsetY;

/**

* targetView 的外切圆半径

*/

private int radius;

/**

* 需要显示提示信息的View

*/

private View targetView;

/**

* 自定义View

*/

private View customGuideView;

/**

* 透明圆形画笔

*/

private Paint mCirclePaint;

/**

* 背景色画笔

*/

private Paint mBackgroundPaint;

/**

* targetView是否已测量

*/

private boolean isMeasured;

/**

* targetView圆心

*/

private int[] center;

/**

* 绘图层叠模式

*/

private PorterDuffXfermode porterDuffXfermode;

/**

* 绘制前景bitmap

*/

private Bitmap bitmap;

/**

* 背景色和透明度,格式 #aarrggbb

*/

private int backgroundColor;

/**

* Canvas,绘制bitmap

*/

private Canvas temp;

/**

* 相对于targetView的位置.在target的那个方向

*/

private Direction direction;

/**

* 形状

*/

private MyShape myShape;

/**

* targetView左上角坐标

*/

private int[] location;

private boolean onClickExit;

private OnClickCallback onclickListener;

private RelativeLayout guideViewLayout;

public void restoreState() {

Log.v(TAG, "restoreState");

offsetX = offsetY = 0;

radius = 0;

mCirclePaint = null;

mBackgroundPaint = null;

isMeasured = false;

center = null;

porterDuffXfermode = null;

bitmap = null;

needDraw = true;

// backgroundColor = Color.parseColor("#00000000");

temp = null;

// direction = null;

}

public int[] getLocation() {

return location;

}

public void setLocation(int[] location) {

this.location = location;

}

public GuideView(Context context) {

super(context);

this.mContent = context;

init();

}

public int getRadius() {

return radius;

}

public void setRadius(int radius) {

this.radius = radius;

}

public void setOffsetX(int offsetX) {

this.offsetX = offsetX;

}

public void setOffsetY(int offsetY) {

this.offsetY = offsetY;

}

public void setDirect

更多推荐

android 给图片蒙上蒙层

本文发布于:2024-03-05 20:36:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1713352.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图片   android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!