用Android studio第一次尝试滑块验证,一开始单纯的做了使用seekbar控件的xml,后来因为发现是属于点击弹出对话框的模式,于是又去查阅alertdialog自定义,各种博主的写的都不错,但是在实践的过程中我也出现了不少报错,最后修修补补总算实现了
点击主要页面的TextView弹出滑块验证对话框,滑动钥匙滑块到进度条尾部终止(这里并没有实现验证方面的功能,只是监听控制滑动)

要用自定义的对话框可以自己先写Layout布局文件,这里是我写的seekbar.xml(就是如上图的对话框样子)
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="310dp"
android:layout_height="180dp"
android:background="@drawable/list_item_bg">
<TextView
android:id="@+id/cross"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="8dp"
android:layout_marginRight="8dp"
android:background="@drawable/crossgray" />
<TextView
android:id="@+id/pleaser"
android:layout_width="wrap_content"