最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android仿微信/支付寶密碼輸入框

 更新時(shí)間:2015年12月29日 09:27:44   作者:yaya_soft  
這篇文章主要介紹了Android仿微信/支付寶密碼輸入框的相關(guān)資料,需要的朋友可以參考下

在用到支付類app時(shí),都有一個(gè)簡密的輸入框。。開始實(shí)現(xiàn)的時(shí)候思路有點(diǎn)問題,后來到github上搜了下,找到了一個(gè)開源的庫看起來相當(dāng)?shù)呐1?,,來個(gè)地址先:

https://github.com/Jungerr/GridPasswordView

效果圖:

這個(gè)開源庫我研究了之后,又有了自己的一個(gè)思路:來個(gè)假的簡密框---底部放一個(gè)EditTextView,頂部放置6個(gè)ImageView的原點(diǎn),控制他們的顯隱來實(shí)現(xiàn)這個(gè)簡密寬

開發(fā)步驟:

1 布局

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 style="@style/common_hm_vw" 
 android:layout_height="50dp" > 
 <LinearLayout 
  android:baselineAligned="false" 
  android:layout_width="match_parent" 
  android:layout_height="50dp" 
android:background="@drawable/sdk2_simple_pwd_bg_" 
  android:orientation="horizontal" > 
  <RelativeLayout 
   style="@style/common_ho_vm" 
   android:layout_weight="1" 
   android:orientation="horizontal" > 
   <ImageView 
    android:id="@+id/sdk2_pwd_one_img" 
    style="@style/common_hm_vm" 
android:layout_centerInParent="true" 
android:src="@drawable/sdk_circle_icon" 
    android:visibility="invisible" /> 
   <View 
    android:layout_width="1dp" 
    android:layout_height="fill_parent" 
android:layout_alignParentRight="true"  android:background="@color/sdk_color_pwd_line" /> 
  </RelativeLayout> 
  <RelativeLayout 
   style="@style/common_ho_vm" 
   android:layout_weight="1" 
   android:orientation="horizontal" > 
   <ImageView 
    android:id="@+id/sdk2_pwd_two_img" 
    style="@style/common_hw_vw" 
android:layout_centerInParent="true" 
android:src="@drawable/sdk_circle_icon" 
    android:visibility="invisible" /> 
   <View 
    android:layout_width="1dp" 
    android:layout_height="fill_parent" 
 android:layout_alignParentRight="true"  android:background="@color/sdk_color_pwd_line" /> 
  </RelativeLayout> 
  <RelativeLayout 
   style="@style/common_ho_vm" 
   android:layout_weight="1" 
   android:orientation="horizontal" > 
   <ImageView 
 android:id="@+id/sdk2_pwd_three_img" 
    style="@style/common_hw_vw" 
   android:layout_centerInParent="true" 
  android:src="@drawable/sdk_circle_icon" 
    android:visibility="invisible" /> 
   <View 
    android:layout_width="1dp" 
    android:layout_height="fill_parent" 
  android:layout_alignParentRight="true" 
 android:background="@color/sdk_color_pwd_line" /> 
  </RelativeLayout> 
  <RelativeLayout 
   style="@style/common_ho_vm" 
   android:layout_weight="1" 
   android:orientation="horizontal" > 
   <ImageView 
    android:id="@+id/sdk2_pwd_four_img" 
    style="@style/common_hw_vw" 
android:layout_centerInParent="true" 
 android:src="@drawable/sdk_circle_icon" 
    android:visibility="invisible" /> 
   <View 
    android:layout_width="1dp" 
    android:layout_height="fill_parent" 
 android:layout_alignParentRight="true"  android:background="@color/sdk_color_pwd_line" /> 
  </RelativeLayout> 
  <RelativeLayout 
   style="@style/common_ho_vm" 
   android:layout_weight="1" 
   android:orientation="horizontal" > 
   <ImageView 
    android:id="@+id/sdk2_pwd_five_img" 
    style="@style/common_hw_vw" 
  android:layout_centerInParent="true" 
android:src="@drawable/sdk_circle_icon" 
    android:visibility="invisible" /> 
   <View 
    android:layout_width="1dp" 
    android:layout_height="fill_parent" 
  android:layout_alignParentRight="true" 
    android:background="@color/sdk_color_pwd_line" /> 
  </RelativeLayout> 
  <RelativeLayout 
   style="@style/common_ho_vm" 
   android:layout_weight="1" 
   android:orientation="horizontal" > 
   <ImageView    android:id="@+id/sdk2_pwd_six_img"     style="@style/common_hw_vw"     android:layout_centerInParent="true"     android:src="@drawable/sdk_circle_icon" 
    android:visibility="invisible" /> 
   <View 
android:layout_width="1dp"    android:layout_height="fill_parent"     android:layout_alignParentRight="true"    android:background="@color/sdk_color_pwd_line" /> 
  </RelativeLayout> 
 </LinearLayout> 
 <EditText 
  android:id="@+id/sdk2_pwd_edit_simple" 
  style="@style/common_hm_vm" 
  android:background="@null" 
  android:cursorVisible="false" 
  android:inputType="numberPassword" 
  android:maxLength="6" 
 android:textColor="@color/sdk2_color_black" /> 
</FrameLayout> 

2:自定義一個(gè)控件來處理輸入、刪除、顯隱等事件

package com.suning.mobile.paysdk.view; 
import android.content.Context; 
import android.text.Editable; 
import android.text.TextWatcher; 
import android.util.AttributeSet; 
import android.view.KeyEvent; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.widget.EditText; 
import android.widget.ImageView; 
import android.widget.LinearLayout; 
import com.suning.mobile.paysdk.R; 
import com.suning.mobile.paysdk.utils.FunctionUtils; 
import com.suning.mobile.paysdk.utils.log.LogUtils; 
/** 
 * 
 * 〈一句話功能簡述〉<br> 
 * 〈功能詳細(xì)描述〉 簡密輸入框 
 */ 
public class SecurityPasswordEditText extends LinearLayout { 
 private EditText mEditText; 
 private ImageView oneTextView; 
 private ImageView twoTextView; 
 private ImageView threeTextView; 
 private ImageView fourTextView; 
 private ImageView fiveTextView; 
 private ImageView sixTextView; 
 LayoutInflater inflater; 
 ImageView[] imageViews; 
 View contentView; 
 public SecurityPasswordEditText(Context context, AttributeSet attrs) { 
  super(context, attrs); 
  inflater = LayoutInflater.from(context); 
  builder = new StringBuilder(); 
  initWidget(); 
 } 
 private void initWidget() { 
  contentView = inflater.inflate(R.layout.sdk_simple_pwd_widget, null); 
  mEditText = (EditText) contentView 
    .findViewById(R.id.sdk_pwd_edit_simple); 
  oneTextView = (ImageView) contentView 
    .findViewById(R.id.sdk_pwd_one_img); 
  twoTextView = (ImageView) contentView 
    .findViewById(R.id.sdk_pwd_two_img); 
  fourTextView = (ImageView) contentView 
    .findViewById(R.id.sdk_pwd_four_img); 
  fiveTextView = (ImageView) contentView 
    .findViewById(R.id.sdk_pwd_five_img); 
  sixTextView = (ImageView) contentView 
    .findViewById(R.id.sdk_pwd_six_img); 
  threeTextView = (ImageView) contentView 
    .findViewById(R.id.sdk_pwd_three_img); 
  LinearLayout.LayoutParams lParams = new LayoutParams( 
    LinearLayout.LayoutParams.MATCH_PARENT, 
    LinearLayout.LayoutParams.WRAP_CONTENT); 
  mEditText.addTextChangedListener(mTextWatcher); 
  mEditText.setOnKeyListener(keyListener); 
  imageViews = new ImageView[] { oneTextView, twoTextView, threeTextView, 
    fourTextView, fiveTextView, sixTextView }; 
  this.addView(contentView, lParams); 
 } 
 TextWatcher mTextWatcher = new TextWatcher() { 
  @Override 
  public void onTextChanged(CharSequence s, int start, int before, 
    int count) { 
  } 
  @Override 
  public void beforeTextChanged(CharSequence s, int start, int count, 
    int after) { 
  } 
  @Override 
  public void afterTextChanged(Editable s) { 
   if (s.toString().length() == ) { 
    return; 
   } 
   if (builder.length() < ) { 
    builder.append(s.toString()); 
    setTextValue(); 
   } 
   s.delete(, s.length()); 
  } 
 }; 
 OnKeyListener keyListener = new OnKeyListener() { 
  @Override 
  public boolean onKey(View v, int keyCode, KeyEvent event) { 
   if (keyCode == KeyEvent.KEYCODE_DEL 
     && event.getAction() == KeyEvent.ACTION_UP) { 
    delTextValue(); 
    return true; 
   } 
   return false; 
  } 
 }; 
 private void setTextValue() { 
  String str = builder.toString(); 
  int len = str.length(); 
  if (len <= ) { 
   imageViews[len - ].setVisibility(View.VISIBLE); 
  } 
  if (len == ) { 
   LogUtils.i("回調(diào)"); 
   LogUtils.i("支付密碼" + str); 
   if (mListener != null) { 
    mListener.onNumCompleted(str); 
   } 
   LogUtils.i("jone", builder.toString()); 
   FunctionUtils.hideSoftInputByView(getContext(), mEditText); 
  } 
 } 
 private void delTextValue() { 
  String str = builder.toString(); 
  int len = str.length(); 
  if (len == ) { 
   return; 
  } 
  if (len > && len <= ) { 
   builder.delete(len - , len); 
  } 
  imageViews[len - ].setVisibility(View.INVISIBLE); 
  ; 
 } 
 StringBuilder builder; 
 public interface SecurityEditCompleListener { 
  public void onNumCompleted(String num); 
 } 
 public SecurityEditCompleListener mListener; 
 public void setSecurityEditCompleListener( 
   SecurityEditCompleListener mListener) { 
  this.mListener = mListener; 
 } 
 public void clearSecurityEdit() { 
  if (builder != null) { 
   if (builder.length() == ) { 
    builder.delete(, ); 
   } 
  } 
  for (ImageView tv : imageViews) { 
   tv.setVisibility(View.INVISIBLE); 
  } 
 } 
 public EditText getSecurityEdit() { 
  return this.mEditText; 
 } 
} 

這樣子其實(shí)也實(shí)現(xiàn)了簡密功能,但是這個(gè)比前面那個(gè)開源庫簡單了許多,當(dāng)然功能也沒有前面的那個(gè)強(qiáng)大。

以上內(nèi)容給大家介紹了Android仿微信/支付寶密碼輸入框的全部敘述,希望大家喜歡。

相關(guān)文章

  • flutter實(shí)現(xiàn)頭部tabTop滾動(dòng)欄

    flutter實(shí)現(xiàn)頭部tabTop滾動(dòng)欄

    這篇文章主要為大家詳細(xì)介紹了flutter實(shí)現(xiàn)頭部tabTop滾動(dòng)欄,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • Android解析服務(wù)器端發(fā)來的xml數(shù)據(jù)示例

    Android解析服務(wù)器端發(fā)來的xml數(shù)據(jù)示例

    Android跟服務(wù)器交互數(shù)據(jù),有時(shí)數(shù)據(jù)量大時(shí),就需要以xml形式的交互數(shù)據(jù),下面與大家分享下使用XmlPullParser來解析xml數(shù)據(jù),感興趣的朋友可以參考下哈
    2013-06-06
  • Android9.0 SystemUI 網(wǎng)絡(luò)信號欄定制修改的流程解析

    Android9.0 SystemUI 網(wǎng)絡(luò)信號欄定制修改的流程解析

    這篇文章主要介紹了Android9.0 SystemUI 網(wǎng)絡(luò)信號欄定制修改的流程,本文通過圖文實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-11-11
  • 一文詳解Jetpack?Android新一代導(dǎo)航管理Navigation

    一文詳解Jetpack?Android新一代導(dǎo)航管理Navigation

    這篇文章主要為大家介紹了Jetpack?Android新一代導(dǎo)航管理Navigation詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-03-03
  • kotlin中EditText賦值Type mismatch方式

    kotlin中EditText賦值Type mismatch方式

    這篇文章主要介紹了kotlin中EditText賦值Type mismatch方式,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-03-03
  • Android apk 插件啟動(dòng)內(nèi)存釋放問題

    Android apk 插件啟動(dòng)內(nèi)存釋放問題

    這篇文章主要介紹了Android apk 插件啟動(dòng)內(nèi)存釋放問題的相關(guān)資料,需要的朋友可以參考下
    2017-06-06
  • android 6.0 權(quán)限授權(quán)方法

    android 6.0 權(quán)限授權(quán)方法

    今天小編就為大家分享一篇android 6.0 權(quán)限授權(quán)方法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-07-07
  • Android RecyclerView布局就這么簡單

    Android RecyclerView布局就這么簡單

    Android RecyclerView布局就這么簡單!RecyclerView比ListView更靈活,更強(qiáng)大,作為一個(gè)android開發(fā)者如果還不知道如何使用android5.X的RecyclerView未免有點(diǎn)說不過去了,本文就為大家講解Android RecyclerView布局,需要的朋友可以參考下
    2016-04-04
  • Android實(shí)現(xiàn)簡單的音樂播放器

    Android實(shí)現(xiàn)簡單的音樂播放器

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)簡單的音樂播放器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-05-05
  • Android自定義View實(shí)現(xiàn)拖拽效果

    Android自定義View實(shí)現(xiàn)拖拽效果

    這篇文章主要為大家詳細(xì)介紹了Android自定義View實(shí)現(xiàn)拖拽效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-11-11

最新評論

保靖县| 定边县| 津市市| 五莲县| 即墨市| 绵阳市| 双柏县| 荃湾区| 静安区| 高碑店市| 阿荣旗| 宁海县| 龙海市| 双流县| 陇西县| 长葛市| 怀宁县| 加查县| 寻乌县| 桓仁| 温泉县| 定西市| 杭锦旗| 易门县| 洞头县| 沾化县| 七台河市| 广丰县| 和顺县| 永城市| 乌拉特后旗| 北流市| 兴和县| 宁晋县| 嫩江县| 蓬溪县| 浦北县| 祥云县| 舟曲县| 枣阳市| 常德市|