0

Ich benutze Android TextInputLayout, um Floating-Label auf EditText anzuzeigen.Viewgroup in einem TextInputLayout macht Floating-Label funktioniert nicht

Aber ich möchte eine ProgressBar auf der linken Seite von EditText zeigen, also habe ich ein relatives Layout innerhalb der TextInputLayout und EditText in diesem relativen Layout hinzugefügt.

damit das Floating-Label nicht funktioniert.

Wenn ich in das relative Layout von der TextInputLayout entfernen und die EditText Kinder direkt davon, dann funktioniert es.

Also muss EditTExt eine direkte Kinder von TextInputLayout sein und wenn ja, wie können wir ein anderes Widget zu EditTexts wie ProgressBar links legen.

Als TextInputLayout inhertis von LinearLayout, Kinder hinzufügen, fügt Kinder vertikal, aber ich möchte Ansichten über EditText hinzufügen.

<android.support.design.widget.TextInputLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/holderName" 

android:layout_height="wrap_content" 

android:layout_width="match_parent"> 


<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

<android.support.design.widget.TextInputEditText 
    android:id="@+id/etField" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:hint="Name" 


    > 
</android.support.design.widget.TextInputEditText> 

    <ProgressBar 
     android:id="@+id/progress" 
     style="?android:attr/progressBarStyle" 
     android:layout_width="16dp" 
     android:layout_height="match_parent" 
     android:indeterminateTint="@color/primary" 
     android:layout_gravity="right|center_vertical" 
     android:layout_marginRight="15dp" 
     android:visibility="visible" 
     /> 


</FrameLayout> 

+0

wo ist Ihr Code Sir? – Remario

+0

Ich habe den Code veröffentlicht, obwohl der Code FrameLayout als untergeordnete Elemente hat, nicht relatives Layout nach der Frage. –

Antwort

0

Diese Funktionalität ist nicht verfügbar. In addView() sucht es direkt nach dem EditText.

Hier ist der Code

@Override 
public void addView(View child, int index, final ViewGroup.LayoutParams params) { 
    if (child instanceof EditText) { 
      mInputFrame.addView(child, new FrameLayout.LayoutParams(params)); 

      // Now use the EditText's LayoutParams as our own and update them to make enough space 
      // for the label 
      mInputFrame.setLayoutParams(params); 
      updateInputLayoutMargins(); 

      setEditText((EditText) child); 
    } else { 
      // Carry on adding the View... 
      super.addView(child, index, params); 
    } 
} 

Also, das erste Kind EditText vom Typ sein müssen.

Wenn Sie diese Funktionalität dann innerhalb RelativeLayout wollen nehmen Sie Ihre TextInputLayout und die ProgressBar und legen Sie die Positionen von Progressbar

Verwandte Themen