• Stars
    star
    197
  • Rank 197,722 (Top 4 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 8 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Android app新手引导,任意View高亮提示,简单易用

EasyGuideView

Android app新手引导高亮提示,简单易用

效果

添加依赖

compile 'com.yuyh.easyguideview:library:1.2.2'

基本使用

// 须在View绘制完成之后调用,否则可能无法准确显示
// offsetX:正数代表从屏幕左侧往右偏移距离,负数表示从屏幕右侧往左偏移距离。Constant.CENTER 表示居中
// offsetY:同理。正数由上到下,负数由下到上。Constant.CENTER 表示居中
public void show(){
    EasyGuide easyGuide = new EasyGuide.Builder(MainActivity.this)
            // 增加View高亮区域,可同时显示多个
            .addHightArea(view, HShape.CIRCLE)
            // 添加箭头指示
            .addIndicator(R.drawable.right_top, loc[0], loc[1] + view.getHeight())
            // 复杂的提示布局,建议通过此方法,较容易控制
            .addView(createTipsView(), 0, loc[1] + view.getHeight(),
                            new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                            ViewGroup.LayoutParams.WRAP_CONTENT))
            // 设置提示信息,默认居中。若需调整,可采用addView形式
            .addMessage("点击菜单显示", 14)
            // 设置确定按钮,默认居中显示在Message下面
            .setPositiveButton("朕知道了~", 15, onClickListener)
            // 是否点击任意区域消失,默认true
            .dismissAnyWhere(true)
            // 若点击作用在高亮区域,是否执行高亮区域的点击事件,默认false
            .performViewClick(true)
            .build();

    easyGuide.show();
}

private View createTipsView() {

    View view = LayoutInflater.from(this).inflate(R.layout.tips_view, null);

    ImageView ivIsee = (ImageView) view.findViewById(R.id.ivIsee);
    ivIsee.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (easyGuide != null) {
                easyGuide.dismiss();
            }
        }
    });

    return view;
}

如何判断绘制完成?可重写activity的void onWindowFocusChanged(boolean hasFocus)方法,建议使用以下方式:

// 等待高亮View加载完成之后再调用显示引导层,例如对于hightLightView高亮来说:
hightLightView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
    @Override
    public void onGlobalLayout() {// 加载完成后回调

        // 务必取消监听,否则会多次调用
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
            hightLightView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        } else {
            hightLightView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
        }

        // TODO 显示高亮布局!

    }
});

新手引导层状态改变监听

easyGuide.setOnStateChangedListener(new OnStateChangedListener() {
    @Override
    public void onShow() {

    }

    @Override
    public void onDismiss() {

    }

    @Override
    public void onHeightlightViewClick(View view) {
        Log.i("TAG", "点击了view:" + view.getId());
    }
});

LICENSES

Copyright (C) 2016 smuyyh

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

BookReader

📕 "任阅" 网络小说阅读器,3D翻页效果、txt/pdf/epub书籍阅读、Wifi传书~
Java
6,562
star
2

ImageSelector

🌁 Android 图片选择器。充分自由定制,极大程度简化使用,支持图库多选/图片预览/单选/照片裁剪/拍照/自定义图片加载方式/自定义色调/沉浸式状态栏
Java
1,599
star
3

SprintNBA

🏀 NBA客户端
Java
632
star
4

CrawlerForReader

Android 本地网络小说爬虫,基于jsoup及xpath
Java
390
star
5

BubblePopupWindow

Android 实现各个方向的气泡弹窗,可控制气泡尖角偏移量。
Java
345
star
6

BankCardFormat

💳 自动格式化银行卡号的EditText,卡号格式化、归属银行及卡别判断
Java
282
star
7

JsonViewer

Android json viewer, to convert json strings to a friendly readable format, it supports expend&collapsed json objects.
Java
195
star
8

IncrementallyUpdate

Android 应用增量更新
C
179
star
9

EasyAdapter

Android 轻量级适配器,简化使用,适应所有的AbsListView、RecyclerView。支持HeaderView与FooterView~
Java
168
star
10

CommonLibary

CommonLibrary主要是自己整理的一些项目开发中常用的工具类、通用UI的集合,尽可能的覆盖Android开发中通用的一些东西
Java
139
star
11

AutoInstall

Android 无需Root实现APK的静默安装
Java
135
star
12

NestedRecyclerView

RecyclerView 嵌套 多Tab 吸顶容器,类似 盒马、朴朴超市 首页。
Java
111
star
13

StickyHeaderListView

仿滴滴打车开具发票页,ListView粘性Header
Java
89
star
14

HardwareTest

Android 各个硬件模块自动化测试。包括LCD、摄像头、键盘、闪光灯、声音、磁盘存储、震动、触摸屏、NFC及各类传感器的测试。
Java
87
star
15

StickyHeaderRecyclerView

RecyclerView 悬浮吸顶 Header,支持阴影、点击事件与状态绑定
Java
75
star
16

easyDAO

easyDAO is a light-weight&fast ORM library for Android that maps objects to SQLite , it becomes much easier to operate the SQLite database.
Java
35
star
17

ReactNativeTools

IntelliJ plugin, to make it easier to execute react-native commands
Java
26
star
18

GitHubWidgets

GitHub html widget, include User Widget、Repo Widget and Activity Widget.
JavaScript
18
star
19

SimpleMail

一个基于POP3和SMTP协议的邮件收发库
Java
10
star
20

ReflectionDemo

从Java反射机制到Android自定义注解框架
Java
10
star
21

AndroidLayoutIDConverter

Android Studio插件。快速生成findViewById代码/ButtefKnife注解/AndroidAnnotations注解~
Java
4
star
22

JustTest

contributions
Java
2
star