2017-10-10 10 views
0

Je suis en train de mettre en œuvre ce type de mise en page « code PIN » sans utiliser une bibliothèque:Insiste ci-dessous mise en page

enter image description here

Je veux utiliser un champ EditText mais mon problème est de mettre en œuvre les underscores en dessous de la EditText champs sous le numéro actuel et le rendre dynamique. Des conseils sur la façon dont je peux mettre en œuvre cela?

Répondre

0

essayer cette utilisation horizontal LinearLayout

enter image description here

<EditText 
     android:id="@+id/edDigit1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="center" 
     android:hint="1" 
     android:imeOptions="actionNext" 
     android:inputType="number" 
     android:maxLength="1" /> 

    <EditText 
     android:id="@+id/edDigit2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="center" 
     android:hint="2" 
     android:imeOptions="actionNext" 
     android:inputType="number" 
     android:maxLength="1" /> 

    <EditText 
     android:id="@+id/edDigit3" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="center" 
     android:hint="3" 
     android:imeOptions="actionNext" 
     android:inputType="number" 
     android:maxLength="1" /> 

    <EditText 
     android:id="@+id/edDigit4" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="center" 
     android:hint="4" 
     android:imeOptions="actionNext" 
     android:inputType="number" 
     android:maxLength="1" /> 

</LinearLayout> 
+0

Merci pour votre réponse! Tout moyen de le faire dans un seul EditText et d'ajouter des underscore dynamiques (par exemple changer sa couleur et son épaisseur après une entrée réussie) sous chaque entrée numérique? – beerprophet

+0

impossible avec un seul texte d'édition @beerprophet –