2017-06-05 122 views
0

我很努力地在屏幕上获得附加的布局,特别是破折号,他们将像一个数字文本字段,因为它是一个代码,下一个数字必须跳转到下一个文本字段,如果这是我必须使用的。 这是当用户收到一个代码(4位数字)他必须输入它,但每场一个数字。 enter image description hereAndroid手机代码

我认为这张图片是自我解释的。谢谢。

+1

我认为这个链接可以帮助你http://lomza.totem-soft.com/pin-input-view-in-android/ – Meenal

+0

看起来很有希望会在一段时间内更新你。 TKS! – JackyBoi

+0

@Meenal tks哥们!工作得很好! – JackyBoi

回答

1

您可以使用此Library易于实现&根据您的需要进行定制。

0

请检查下面的代码是否工作正常。只需将以下代码复制粘贴到您的xml布局文件。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_test" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 



<LinearLayout 
    android:layout_width="match_parent" 
    android:orientation="vertical" 
    android:layout_height="match_parent"> 


    <TextView 
     android:layout_width="wrap_content" 
     android:text="ENTER CODE" 
     android:textSize="18sp" 
     android:textColor="@android:color/holo_blue_dark" 
     android:layout_gravity="center" 
     android:layout_height="wrap_content" /> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:orientation="horizontal" 
     android:layout_margin="10dp" 
     android:layout_gravity="center" 
     android:layout_height="wrap_content"> 


     <EditText 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:imeOptions="actionNext" 
      android:maxLength="1" 
      android:inputType="number" 
      android:layout_height="wrap_content" /> 


     <EditText 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:imeOptions="actionNext" 
      android:maxLength="1" 
      android:inputType="number" 
      android:layout_height="wrap_content" /> 

     <EditText 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:imeOptions="actionNext" 
      android:maxLength="1" 
      android:inputType="number" 
      android:layout_height="wrap_content" /> 

     <EditText 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:imeOptions="actionDone" 
      android:maxLength="1" 
      android:inputType="number" 
      android:layout_height="wrap_content" /> 


    </LinearLayout> 

    <TextView 
     android:layout_width="wrap_content" 
     android:text="00:32" 
     android:layout_gravity="center" 
     android:layout_marginTop="10dp" 
     android:layout_height="wrap_content" /> 


    <TextView 
     android:layout_width="wrap_content" 
     android:text="Resend Code" 
     android:textSize="15sp" 
     android:textColor="@android:color/holo_blue_dark" 
     android:layout_gravity="center" 
     android:layout_marginTop="10dp" 
     android:layout_height="wrap_content" /> 


    <Button 
     android:layout_width="match_parent" 
     android:text="verify" 
     android:layout_marginTop="10dp" 
     android:background="@android:color/holo_blue_dark" 
     android:layout_height="wrap_content" /> 

</LinearLayout> 

集的MaxLength = 1的EditText该诀窍 并请根据您的要求给保证金。