armandasalmd armandasalmd - 1 month ago 18
Android Question

Android remove EditText selection

enter image description here

I have 2

editText
s, whenewer I launch app first(orange) edit text is getting selected automaticaly.

I tried clear focus, but this hadn't worked for me.

<LinearLayout
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/event_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="textPersonName"
android:hint="@string/edit_text_title" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/txtInputLayoutPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/event_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="textMultiLine"
android:hint="@string/edit_text_description" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>



How to make first edit text look like second ?

Answer
                   <LinearLayout
                    style="@style/Widget.CardContent"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">


    <!-- Dummy item to prevent AutoCompleteTextView from receiving focus -->
                          <LinearLayout
                          android:focusable="true" 
                          android:focusableInTouchMode="true"
                          android:layout_width="0px" 
                          android:layout_height="0px"/>

                    <android.support.design.widget.TextInputLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">
                        <EditText
                            android:id="@+id/event_title"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:inputType="textPersonName"
                            android:hint="@string/edit_text_title" />
                    </android.support.design.widget.TextInputLayout>
                    <android.support.design.widget.TextInputLayout
                        android:id="@+id/txtInputLayoutPassword"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content">
                        <EditText
                            android:id="@+id/event_description"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:inputType="textMultiLine"
                            android:hint="@string/edit_text_description" />
                    </android.support.design.widget.TextInputLayout>
                </LinearLayout>
Comments