如何在android studio中的drawable文件夹中使用自己的图片进行验证码?

时间:2021-02-13 00:31:26

i want to generate image captcha (i have own those images) in android studio. please help me or show me the example, any respon will be so appreciate, thanks. sorry for my bad eng

我想在android studio中生成图像验证码(我有自己的图像)。请帮助我或给我看一个例子,任何回应都会如此欣赏,谢谢。抱歉我的坏人

2 个解决方案

#1


2  

Visit this link. Its a library for generating captcha in Android. Just add the dependencies into your build.gradel and Rebuild the project and you can add captcha where ever you want.

访问此链接。它是一个用于在Android中生成验证码的库。只需将依赖项添加到build.gradel并重建项目,就可以在任何需要的地方添加验证码。

#2


0  

To generate Captcha Code in Android use

在Android中使用Captcha代码

1> Generate Random Number

1>生成随机数

public static String CapCodeGen(int limit) {

public static String CapCodeGen(int limit){

// add caracter to generate captcha Code

//添加caracter以生成验证码

    String chars = "0123456789";
    Random r = new Random();
    StringBuffer buf = new StringBuffer();

    buf.append(chars.charAt(r.nextInt(10)));
    for (int i = 0; i < limit; i++) {
        buf.append(chars.charAt(r.nextInt(chars.length())));
    }

    return String.valueOf(buf);

}

2> Set to TextView with captcha backgrount it will look like captach Image

2>使用验证码背景设置为TextView,它看起来像captach Image

#1


2  

Visit this link. Its a library for generating captcha in Android. Just add the dependencies into your build.gradel and Rebuild the project and you can add captcha where ever you want.

访问此链接。它是一个用于在Android中生成验证码的库。只需将依赖项添加到build.gradel并重建项目,就可以在任何需要的地方添加验证码。

#2


0  

To generate Captcha Code in Android use

在Android中使用Captcha代码

1> Generate Random Number

1>生成随机数

public static String CapCodeGen(int limit) {

public static String CapCodeGen(int limit){

// add caracter to generate captcha Code

//添加caracter以生成验证码

    String chars = "0123456789";
    Random r = new Random();
    StringBuffer buf = new StringBuffer();

    buf.append(chars.charAt(r.nextInt(10)));
    for (int i = 0; i < limit; i++) {
        buf.append(chars.charAt(r.nextInt(chars.length())));
    }

    return String.valueOf(buf);

}

2> Set to TextView with captcha backgrount it will look like captach Image

2>使用验证码背景设置为TextView,它看起来像captach Image