Additional constraints: both edit fields are placed to each other horizontally and the hint is long enough to be above them
Long enough hint above two edit fields
======= ==================
Additional constraints: both edit fields are placed to each other horizontally and the hint is long enough to be above them
Long enough hint above two edit fields
======= ==================
It's impossible for TextInputLayout
to have 2 EditText
as children. Doing this throws you an InflateException
like this :
android.view.InflateException: Binary XML file line #xxx: We already have an EditText, can only have one
So I assume that it's a Material Design guideline, and having one TextInputLayout
with 2 EditText
is anti-pattern to google's recommandations.
Try this:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000"
android:gravity="center"
android:text="Only one hint above two edit fields"
android:textSize="20dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/et1"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/et2"
/>
</LinearLayout>
</LinearLayout>
If you ant to hide the TextView
, you can use a TextChangedListener
and set the Visibilty
to INVISIBLE
if the text equals ""
.