androidandroid-layouttextinputlayout

EditText is not visible inside TextInputLayout


I have EditText, and it is placed inside the TextInputLayout. But the problem is EditText is not visible after deploying on the device. My code is below.

<TableRow
    android:id="@+id/tableRow2"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:layout_width="0dp"
        android:layout_weight="1">

        <android.support.design.widget.TextInputLayout
            android:id="@+id/textInputRFID"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginRight="5dp"
            android:layout_marginBottom="3dp"
            android:layout_weight=".70"
            android:orientation="horizontal">

            <EditText
                android:id="@+id/txtRFID"
                android:inputType="text"
                android:layout_weight=".70"
                android:layout_height="wrap_content"
                android:layout_width="0dp"
                android:hint="TAG ID"
                style="@style/textview_text" />
        </android.support.design.widget.TextInputLayout>

        <Button
            android:text="Start"
            android:id="@+id/BtnStartStop"
            android:background="@drawable/styl_blue_button"
            style="@style/textview_text"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight=".30" />
    </LinearLayout>
</TableRow>

Solution

  • The reason is because you are setting layout_width to 0. Remove layout_weight in editText element and change the layout_width to match_parent.

     <EditText
           android:id="@+id/txtRFID"
           android:inputType="text"
           android:layout_height="wrap_content"
           android:layout_width="match_parent"
           android:hint="TAG ID"/>