0

I have an Activity. And its Layout is as below.

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="15dp"
    android:background="@drawable/my_profile_background"
    android:orientation="vertical">

        <android.support.design.widget.TextInputLayout
            android:id="@+id/layEdtEmails"
            style="@style/edittextStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp">

            <EditText
                android:id="@+id/edtEmail"
                style="@style/edittextStyleHint"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/prompt_email"
                android:inputType="textEmailAddress"
                android:maxLength="50"
                android:maxLines="1"
                android:singleLine="true">
            </EditText>

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:orientation="horizontal">               

                <android.support.design.widget.TextInputLayout
                    android:id="@+id/layEdtPasswords"
                    style="@style/edittextStyle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:layout_marginTop="5dp">

                    <EditText
                        android:id="@+id/edtPassword"
                        style="@style/edittextStyleHint"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/prompt_password"
                        android:inputType="textPassword"
                        android:maxLength="15" />
                </android.support.design.widget.TextInputLayout>
        </LinearLayout>
    </LinearLayout>

The problem is that, the First editText gets Automatically focussed when Activity Starts. I want to clear that focus when activity starts. In xml of editText I tried to put focusable as false. But it affects my further coding.

Chandan kushwaha
  • 941
  • 6
  • 26

1 Answers1

0

Add the android:focusable="true" and android:focusableInTouchMode="true" elements in the parent layout of EditText.

Christian
  • 748
  • 7
  • 23