Rakesh
Rakesh

Reputation: 2790

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>

Upvotes: 2

Views: 814

Answers (2)

Rajat Kumar Tyagi
Rajat Kumar Tyagi

Reputation: 116

Here you are using the width for the edit text 0dp which may be creating the issue, so change that to the match_parent or wrap_content same as mentioned below:

<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="wrap_content"
                    android:hint="TAG ID"
                    style="@style/textview_text" />
            </android.support.design.widget.TextInputLayout>

I hope it will work for you.

Upvotes: 0

John Joe
John Joe

Reputation: 12803

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"/>

Upvotes: 3

Related Questions