Android如何实现新手指引操作

本人是学习借鉴鸿阳大神的

首先在build.grade文件中导入    

compile 'com.isanwenyu.highlight:highlight:1.8.0'
布局文件如下:
 
  
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#f00"
    android:id="@+id/id_container"
    >
    
        android:id="@+id/iv_01"
      android:src="@mipmap/wen02"
      android:layout_alignParentBottom="true"
      android:layout_margin="10dp"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />
            android:id="@+id/iv_02"
        android:src="@mipmap/text"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_margin="10dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
            android:id="@+id/iv_03"
        android:src="@mipmap/qb_photo"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="160dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />



 
  
package qb.example.com.hongyanhighlight;

import android.graphics.Bitmap;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import zhy.com.highlight.HighLight;
import zhy.com.highlight.interfaces.HighLightInterface;
import zhy.com.highlight.position.OnBottomPosCallback;
import zhy.com.highlight.position.OnLeftPosCallback;
import zhy.com.highlight.position.OnRightPosCallback;
import zhy.com.highlight.position.OnTopPosCallback;
import zhy.com.highlight.shape.BaseLightShape;
import zhy.com.highlight.shape.CircleLightShape;
import zhy.com.highlight.shape.OvalLightShape;
import zhy.com.highlight.shape.RectLightShape;
import zhy.com.highlight.view.HightLightView;

public class MainActivity extends AppCompatActivity
{

    private HighLight mHightLight;
    private ImageView iv_01;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        iv_01=(ImageView)findViewById(R.id.iv_01);
        iv_01.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.e("text","加油");
            }
        });
        showNextTipView();

    }
    private boolean isBoolean=false;
    public  void showNextTipView(){
        mHightLight = new HighLight(MainActivity.this)//
                .anchor(findViewById(R.id.id_container))//如果是Activity上增加引导层,不需要设置anchor
                .autoRemove(false)
                .enableNext()
                .setOnLayoutCallback(new HighLightInterface.OnLayoutCallback() {
                    @Override
                    public void onLayouted() {
                        //界面布局完成添加tipview
                        if(!isBoolean){
                            isBoolean=true;
                        mHightLight.addHighLight(R.id.iv_01,R.layout.layout_01,new OnTopPosCallback(),new CircleLightShape())
                                .addHighLight(R.id.iv_02,R.layout.layout_02,new OnTopLeftPosCallBack(0),new CircleLightShape())
                                .addHighLight(R.id.iv_03,R.layout.layout_03,new OnTopCenterLeftPosCallBack(40),new CircleLightShape());
                        //然后显示高亮布局
                       //这里OnTopLeftPosCallBack和OnTopCenterLeftPosCallBack是自定义继承与OnBaseCallback
                       //有需要的朋友可以自定义,这个主要用于用户放置layout的位置

                        mHightLight.show();
                        Log.e("text","11111111");
                        }
                    }
                })
                .setClickCallback(new HighLight.OnClickCallback() {
                    @Override
                    public void onClick() {
                        Toast.makeText(MainActivity.this, "clicked and show next tip view by yourself", Toast.LENGTH_SHORT).show();
                        mHightLight.next();
                    }
                });


    }


}



你可能感兴趣的:(QBAndroid)