2017-03-06 6 views
1

Ich verwende TextInputLayout von Android Design-Bibliothek Version 25.1.1. Mit dem folgenden Code:TextInputLayout passwordToggle mit abgerundeten Ecken

<android.support.design.widget.TextInputLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:local="http://schemas.android.com/apk/res-auto" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    local:passwordToggleEnabled="true" 
    local:hintEnabled="false"> 
    <android.support.design.widget.TextInputEditText 
    android:id="@+id/confirmationEditText" 
    android:singleLine="true" /> 
</android.support.design.widget.TextInputLayout> 

Aber wenn Kennwort Toggle-Symbol gedrückt wird, dessen Welleneffekt über dem Hintergrund von TextInput- gezogen: Background pressed state

Wie kann ich abgerundeten Ecken Radius für passwordToggle? Kann ich auf den vorhandenen Hintergrund verweisen und ihn mit den erforderlichen Eigenschaften "umbrechen" (wie finde ich den Pfad für das Standard-Zeichenfeld, das von toggle verwendet wird)?

Antwort

0

Use Custom Form hierfür:

<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
     <gradient 
      android:endColor="@color/something" 
      android:centerColor="@color/something_else" 
      android:startColor="@color/something_else_still" 
      android:angle="270" /> 
     <corners 
      android:radius="3dp" /> 
     <padding 
      android:left="10dp" 
      android:top="10dp" 
      android:right="10dp" 
      android:bottom="10dp" /> 
    </shape> 
3

Ich habe versucht, auf neues Projekt zu implementieren Ihr Szenario zu verstehen.

Bitte werfen Sie einen Blick in die Lösung. Ich habe einen Screenshot von, wie es aussehen wird.

enter image description here

Sie haben ziehbar in ziehbar Ordner enthalten und stellen Sie ihn in den Hintergrund von TextInputEditText

round_corner_toggle.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
    <item android:left="20dp"> 
     <shape android:shape="rectangle" > 
      <size android:height="20dp" /> 
      <solid android:color="#d8d8d8" /> 
      <corners android:radius="5dp" /> 
     </shape> 
    </item> 

    <item android:right="60dp"> 
     <shape android:shape="rectangle" > 
      <size android:height="20dp" /> 
      <solid android:color="#ecf0f1" /> 
      <corners android:radius="5dp" /> 

     </shape> 
    </item> 
</layer-list> 

Inhalte für TextInputLayout

  <android.support.design.widget.TextInputLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       app:counterEnabled="true" 
       app:counterMaxLength="8" 
       android:background="#FFFFFF" 
       app:passwordToggleEnabled="true" 
       app:passwordToggleTint="@color/colorPrimary"> 

       <android.support.design.widget.TextInputEditText 
        android:id="@+id/tietPassword" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:hint="Password" 
        android:background="@drawable/round_corner_toggle" 
        android:inputType="textPassword" 
        android:padding="@dimen/activity_horizontal_margin" 
        android:maxLength="8" /> 
      </android.support.design.widget.TextInputLayout> 
    </LinearLayout>