滑块验证码seekbar与alertdialog自定义布局

这篇博客介绍了如何在Android Studio中通过自定义布局和使用Seekbar实现滑块验证码功能,点击TextView弹出对话框,滑动滑块至终点。尽管没有涉及验证功能的实现,但详细讲解了弹出对话框的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用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"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值