Giter VIP home page Giter VIP logo

guideview's Introduction

  • GuideView

  • 本系统能够快速的为一个Activity里的任何一个View控件创建一个遮罩式的导航页,并且可以再高亮区域绘制任何你想要的布局或者lottie动画等炫酷效果

  • 工作原理

  • 首先它需要一个目标View或者它的id,我们通过findViewById来得到这个View,计算它在屏幕上的区域targetRect,通过这个区域,开始绘制一个覆盖整个Activity的遮罩,可以定义遮罩的颜色和透明度,然而目标View被绘制成透明从而实现高亮的效果。接下来是在相对于这个targetRect的区域绘制一些图片或者文字。我们把这样一张图片或者文字抽象成一个Component接口,设置文字或者图片,所有的图片文字都是相对于targetRect来定义的。可以设定额外的x,y偏移量,可以对遮罩系统设置可见状态的发生变化时的监听回调,可以对遮罩系统设置开始和结束时的动画效。

  • 注意:具体用法参见demo,内附详细注释

  • 使用方法

  • 1.添加gradle依赖

    implementation 'com.binioter:guideview:1.0.0'
    
  • 2.编写用于在高亮区域周围展示的component

  •  public class SimpleComponent implements Component {
         
           @Override public View getView(LayoutInflater inflater) {
         
             LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.layer_frends, null);
             ll.setOnClickListener(new View.OnClickListener() {
               @Override public void onClick(View view) {
                 Toast.makeText(view.getContext(), "引导层被点击了", Toast.LENGTH_SHORT).show();
               }
             });
             return ll;
           }
         
           @Override public int getAnchor() {
             return Component.ANCHOR_BOTTOM;
           }
         
           @Override public int getFitPosition() {
             return Component.FIT_END;
           }
         
           @Override public int getXOffset() {
             return 0;
           }
         
           @Override public int getYOffset() {
             return 10;
       }
     }
    
  • 3.展示引导蒙层,并监听蒙层展示、隐藏事件

  •    public void showGuideView() {
          GuideBuilder builder = new GuideBuilder();
          builder.setTargetView(header_imgbtn)
                  .setAlpha(150)
                  .setHighTargetCorner(20)
                  .setHighTargetPadding(10);
          builder.setOnVisibilityChangedListener(new GuideBuilder.OnVisibilityChangedListener() {
            @Override
            public void onShown() {
            }
      
            @Override
            public void onDismiss() {
              showGuideView2();
            }
          });
      
          builder.addComponent(new SimpleComponent());
          guide = builder.createGuide();
          guide.show(SimpleGuideViewActivity.this);
    

License

    Copyright 2016 binIoter

    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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.