Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如果写多个引导控件比较复杂 #28

Open
gincoo opened this issue Aug 21, 2017 · 3 comments
Open

如果写多个引导控件比较复杂 #28

gincoo opened this issue Aug 21, 2017 · 3 comments

Comments

@gincoo
Copy link

gincoo commented Aug 21, 2017

如果写多个引导控件比较复杂,两个就要实例两次,build两次,有点复杂,如果能写进build里就好了

@ZhaoSiBo
Copy link

ZhaoSiBo commented Sep 7, 2017

目前遇到同样问题,一直期望能自己把接口抽取出来,不过功力不够,,,

@ZhaoSiBo
Copy link

ZhaoSiBo commented Sep 7, 2017

private void showGuideView(final View view, final int srcRecourse, final int mode) {
view.post(new Runnable() {
@OverRide
public void run() {
final GuideBuilder builder = new GuideBuilder();
builder.setTargetView(view)
.setAlpha(150)
.setHighTargetCorner(20)
.setHighTargetPadding(10)
.setHighTargetGraphStyle(Component.CIRCLE)
.setOverlayTarget(false)
.setOutsideTouchable(false);
builder.setOnVisibilityChangedListener(new GuideBuilder.OnVisibilityChangedListener() {
@OverRide
public void onShown( ) {
}
@OverRide
public void onDismiss() {
switch (view.getId()){
case R.id.set_record:
showGuideView(btn_scan,R.drawable.mask_scan_map_activity,Component.ANCHOR_TOP);
break;
case R.id.button_scan:
break;
}
}
});

            builder.addComponent(new AbstractComponent() {
                @Override
                public int getAnchor() {
                    return mode;
                }
                @Override
                public View getView(LayoutInflater inflater) {
                    RelativeLayout ll = (RelativeLayout) inflater.inflate(R.layout.layer_frends, null);
                    ImageView img = (ImageView) ll.findViewById(R.id.iv_point_mask);
                    img.setImageResource(srcRecourse);


                    ll.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            Toast.makeText(view.getContext(), "引导层被点击了", Toast.LENGTH_SHORT).show();
                        }
                    });
                    return ll;
                }

            });
            guide = builder.createGuide();
            guide.setShouldCheckLocInWindow(false);
            guide.show(MyMap.this);
        }
    });
}

通过一个方法在一个界面里可以多次调用,不过结构并不好,有需求你可以再改,因为我的需求是遮盖固定显示在屏幕最下方,所以我改过源码中的宽高计算,不知道对你有没有影响,不过在这段代码里应该没什么影响

@silentegao
Copy link

虽然没有时间研究作者的核心代码块并且重构,但是在作者的基础上进行“投机取巧”的利用,也完成了复杂多控件引导的实现,有兴趣的可以在下方回帖交流

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants