欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android實(shí)現(xiàn)密碼明密文切換(小眼睛)

 更新時(shí)間:2022年08月02日 10:53:56   作者:JH學(xué)編程  
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)密碼明密文切換,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android實(shí)現(xiàn)密碼明密文切換的具體代碼,供大家參考,具體內(nèi)容如下

小眼睛在密碼欄右邊!

奉上我使用的素材:

添加圖片到res/darwable中

對(duì)安卓的知識(shí)掌握的非常淺,只知道 圖片名稱不要大寫,大寫會(huì)報(bào)錯(cuò)!
如果格式正確仍會(huì)報(bào)錯(cuò)的話,則 在gradle里加上這兩句,俺也不懂為什么,都沒有講原理的。

aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false

編輯登錄頁(yè).xml

文本+可編輯文本框+小眼睛圖片+按鈕
小眼睛只要寫一個(gè)ImageView即可

<LinearLayout
? ? ? ? ? ? android:id="@+id/ll_username"
? ? ? ? ? ? android:layout_below="@id/iv"
? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? android:layout_marginTop="60dp"
? ? ? ? ? ? android:layout_marginLeft="10dp"
? ? ? ? ? ? android:layout_marginRight="10dp"
? ? ? ? ? ? android:layout_marginBottom="5dp"
? ? ? ? ? ? android:layout_centerVertical="true"
? ? ? ? ? ? android:background="#6B009688">
? ? ? ? <TextView
? ? ? ? ? ? ? ? android:id="@+id/tv_login_username"
? ? ? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:text="賬號(hào):"
? ? ? ? ? ? ? ? android:padding="10dp"
? ? ? ? ? ? ? ? android:textSize="20dp"
? ? ? ? ? ? ? ? android:textColor="@color/white"/>
? ? ? ? <EditText
? ? ? ? ? ? ? ? android:id="@+id/et_login_username"
? ? ? ? ? ? ? ? android:maxLines="1"
? ? ? ? ? ? ? ? android:maxLength="16"
? ? ? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:layout_marginLeft="10dp"
? ? ? ? ? ? ? ? android:background="@null"/>
? ? </LinearLayout>
? ? <LinearLayout
? ? ? ? ? ? android:id="@+id/ll_password"
? ? ? ? ? ? android:layout_below="@id/ll_username"
? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? android:layout_marginLeft="10dp"
? ? ? ? ? ? android:layout_marginRight="10dp"
? ? ? ? ? ? android:layout_centerVertical="true"
? ? ? ? ? ? android:background="#6B009688">
? ? ? ? <TextView
? ? ? ? ? ? ? ? android:id="@+id/tv_login_password"
? ? ? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:text="密碼:"
? ? ? ? ? ? ? ? android:padding="10dp"
? ? ? ? ? ? ? ? android:textSize="20dp"
? ? ? ? ? ? ? ? android:textColor="@color/white"/>
? ? ? ? <EditText
? ? ? ? ? ? ? ? android:id="@+id/et_login_password"
? ? ? ? ? ? ? ? android:maxLines="1"
? ? ? ? ? ? ? ? android:maxLength="6"
? ? ? ? ? ? ? ? android:layout_width="255dp"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:layout_marginLeft="10dp"
? ? ? ? ? ? ? ? android:background="@null"/>
? ? ? ? <ImageView android:layout_width="20dp"
? ? ? ? ? ? ? ? ? ?android:layout_height="20dp"
? ? ? ? ? ? ? ? ? ?android:layout_marginTop="14dp"
? ? ? ? ? ? ? ? ? ?android:id="@+id/display_password"/>
? ? </LinearLayout>
? ? <LinearLayout
? ? ? ? ? ? android:id="@+id/ll_btm"
? ? ? ? ? ? android:layout_below="@id/ll_password"
? ? ? ? ? ? android:gravity="center"
? ? ? ? ? ? android:orientation="vertical"
? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? android:layout_height="wrap_content">
? ? ? ? <Button
? ? ? ? ? ? ? ? android:id="@+id/btn_login"
? ? ? ? ? ? ? ? android:layout_width="300dp"
? ? ? ? ? ? ? ? android:layout_height="50dp"
? ? ? ? ? ? ? ? android:layout_marginTop="50dp"
? ? ? ? ? ? ? ? android:text="登錄"
? ? ? ? ? ? ? ? android:textSize="18dp"
? ? ? ? ? ? ? ? android:background="@color/white"
? ? ? ? />
? ? </LinearLayout>

編輯登錄頁(yè)小眼睛功能.java

public class LoginActivity extends AppCompatActivity implements View.OnClickListener {

? ? private EditText loginUsername;
? ? private EditText loginPassword;
? ? private Button login;
? ? private ImageView displayPassword;
? ? private boolean isHideFirst = false;


? ? @Override
? ? protected void onCreate(Bundle savedInstanceState) {
? ? ? ? super.onCreate(savedInstanceState);
? ? ? ? setContentView(R.layout.activity_login);

? ? ? ? ActionBar actionBar = getSupportActionBar();
? ? ? ? if (actionBar != null) {
? ? ? ? ? ? actionBar.hide();
? ? ? ? }
? ? ? ? //隱藏標(biāo)題欄

? ? ? ? login = findViewById(R.id.btn_login);
? ? ? ? loginUsername = findViewById(R.id.et_login_username);
? ? ? ? loginPassword = findViewById(R.id.et_login_password);
? ? ? ? displayPassword = findViewById(R.id.display_password);

? ? ? ? login.setOnClickListener(this);
? ? ? ? displayPassword.setOnClickListener(this);
? ? ? ? displayPassword.setImageResource(R.drawable.open);
? ? }

? ? @Override
? ? public void onClick(View v){
? ? ? ? switch (v.getId()) {
? ? ? ? ? ? case R.id.display_password:{
? ? ? ? ? ? ? ? if (isHideFirst) {
? ? ? ? ? ? ? ? ? ? displayPassword.setImageResource(R.drawable.open);
? ? ? ? ? ? ? ? ? ? HideReturnsTransformationMethod method1 = HideReturnsTransformationMethod.getInstance();
? ? ? ? ? ? ? ? ? ? loginPassword.setTransformationMethod(method1);
? ? ? ? ? ? ? ? ? ? isHideFirst = false;
? ? ? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? ? ? displayPassword.setImageResource(R.drawable.close);
? ? ? ? ? ? ? ? ? ? TransformationMethod method = PasswordTransformationMethod.getInstance();
? ? ? ? ? ? ? ? ? ? loginPassword.setTransformationMethod(method);
? ? ? ? ? ? ? ? ? ? isHideFirst = true;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? int index = loginPassword.getText().toString().length();
? ? ? ? ? ? ? ? loginPassword.setSelection(index);
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
? ? ? ? ? ? case R.id.btn_login: {
?? ??? ??? ??? ?//。。。。。
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
? ? ? ? }
? ? }
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android開發(fā)AsmClassVisitorFactory使用詳解

    Android開發(fā)AsmClassVisitorFactory使用詳解

    這篇文章主要為大家介紹了Android開發(fā)AsmClassVisitorFactory使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-06-06
  • Android第三方登錄之QQ登錄

    Android第三方登錄之QQ登錄

    這篇文章主要為大家詳細(xì)介紹了Android第三方登錄之QQ登錄,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-10-10
  • Android 保存文件路徑方法

    Android 保存文件路徑方法

    今天小編就為大家分享一篇Android 保存文件路徑方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-08-08
  • Android不使用自定義布局情況下實(shí)現(xiàn)自定義通知欄圖標(biāo)的方法

    Android不使用自定義布局情況下實(shí)現(xiàn)自定義通知欄圖標(biāo)的方法

    這篇文章主要介紹了Android不使用自定義布局情況下實(shí)現(xiàn)自定義通知欄圖標(biāo)的方法,實(shí)例分析了Android通知欄圖標(biāo)的創(chuàng)建技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-12-12
  • Android實(shí)現(xiàn)TextView兩端對(duì)齊的方法

    Android實(shí)現(xiàn)TextView兩端對(duì)齊的方法

    這篇文章主要介紹了Android實(shí)現(xiàn)TextView兩端對(duì)齊的方法,需要的朋友可以參考下
    2016-01-01
  • 基于Android實(shí)現(xiàn)仿QQ5.0側(cè)滑

    基于Android實(shí)現(xiàn)仿QQ5.0側(cè)滑

    本課程將帶領(lǐng)大家通過自定義控件實(shí)現(xiàn)QQ5.0側(cè)滑菜單,課程將循序漸進(jìn),首先實(shí)現(xiàn)最普通的側(cè)滑菜單,然后引入屬性動(dòng)畫與拖動(dòng)菜單效果相結(jié)合,最終實(shí)現(xiàn)QQ5.0側(cè)滑菜單效果。通過本課程大家會(huì)對(duì)側(cè)滑菜單有更深層次的了解,通過自定義控件和屬性動(dòng)畫打造千變?nèi)f化的側(cè)滑菜單效果
    2015-12-12
  • Android開發(fā)控制ScrollView滑動(dòng)速度的方法

    Android開發(fā)控制ScrollView滑動(dòng)速度的方法

    這篇文章主要介紹了Android開發(fā)控制ScrollView滑動(dòng)速度的方法,結(jié)合實(shí)例形式分析了Android編程中ScrollView滑動(dòng)事件相關(guān)操作技巧,需要的朋友可以參考下
    2017-02-02
  • 淺談Android應(yīng)用安全防護(hù)和逆向分析之a(chǎn)pk反編譯

    淺談Android應(yīng)用安全防護(hù)和逆向分析之a(chǎn)pk反編譯

    我們有時(shí)候在某個(gè)app上見到某個(gè)功能,某個(gè)效果蠻不錯(cuò)的,我們想看看對(duì)方的思路怎么走的,這時(shí)候,我們就可以通過反編譯來編譯該apk,拿到代碼,進(jìn)行分析。
    2021-06-06
  • 如何使用Mock修改Android設(shè)備上的features

    如何使用Mock修改Android設(shè)備上的features

    這篇文章主要介紹了如何使用Mock修改Android設(shè)備上的features,想了解Mock的同學(xué)可以參考下
    2021-04-04
  • Android仿美團(tuán)分類下拉菜單實(shí)例代碼

    Android仿美團(tuán)分類下拉菜單實(shí)例代碼

    這篇文章主要為大家詳細(xì)介紹了Android仿美團(tuán)分類下拉菜單實(shí)例代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-05-05

最新評(píng)論