5

I have a layout with a single TextInputLayout with an EditText inside it.

When the layout is loaded the EditText is immediately in edit mode, the keyboard is not up but the cursor is blinking and the hint is not inside the EditText but above it.

I want the hint to be animated out of the EditText only the the use first clicks the EditText.

How can I accomplish that? I have tried clearFocus() on both the EditText and the TextInputLayout.

My xml:

<android.support.design.widget.TextInputLayout
            android:id="@+id/textInputLayout"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">

            <EditText
                android:singleLine="true"
                android:id="@+id/case_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Case name" >
                </EditText>

        </android.support.design.widget.TextInputLayout>
Aviran
  • 5,160
  • 7
  • 44
  • 76
  • 1
    @Kuffs android:windowSoftInputMode="stateHidden" does not work either, you are welcome to try. – Aviran Jul 21 '15 at 07:43
  • Maybe the question I suggested was not a good example but there are many others asking the same thing. Please use the search. http://stackoverflow.com/questions/5550429/edittext-android-automatic-focus Check all answers not just the accepted ones. – Kuffs Jul 21 '15 at 07:47
  • This one has most activity http://stackoverflow.com/questions/1555109/stop-edittext-from-gaining-focus-at-activity-startup – Kuffs Jul 21 '15 at 07:49
  • @Kuffs this is not about the EditText, it's more about the TextInputLayout which is fairly new component with not a lot of reference. – Aviran Jul 21 '15 at 07:49
  • The TextInputLayout is a wrapper around the EditText and is largely irrelevant. To achieve the effect you asked for, you need to prevent focus on the EditText. – Kuffs Jul 21 '15 at 07:51
  • I've tried most of the suggestions there, they on the best case scenario I was able to remove focus, but the EditText's hint was also removed – Aviran Jul 21 '15 at 08:08
  • Add the `android:focusable="true`" and `android:focusableInTouchMode="true"` elements in the parent layout of EditText. – Christian Sep 14 '17 at 19:38
  • In case anyone (like me) is confused about how to interpret these pieces of advice, it does work to add `android:focusableInTouchMode="true"` to the immediate parent of the TextInputLayout (not the parent of the EditText). – pbergson Feb 07 '18 at 20:58

1 Answers1

-1

try this

editText.setCursorVisible(false)
Android Android
  • 724
  • 1
  • 7
  • 20