Search code examples
androidandroid-edittextfocusandroid-softkeyboardsoft-keyboard

EditText not getting selected, but popping keyboard up


My soft keyboard pops up on an activity with an edit text, but I still have to press the edit text to be able to type into it, otherwise pressing keys on the keyboard do nothing

I am using requestFocus() as well as android:focusable="true" as well as android:focusableInTouchMode="true"

thoughts?

I do not have another edit text in this activity or within the fragment that also loads in this activity (hope thats a clue for someone, because I am out of ideas, for now)

    <EditText
    android:id="@+id/mainText"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="@dimen/ten_dp"
    android:layout_marginRight="@dimen/ten_dp"
    android:background="@android:color/transparent"
    android:hint="@string/write_something"
    android:gravity="top"
    android:drawablePadding="@dimen/ten_dp"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:inputType="textCapSentences|textMultiLine"
    android:scrollHorizontally="false" />

Manifest Entry

    <activity
        android:name=".MyActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:windowSoftInputMode="stateVisible|adjustResize" />

Solution

  • What worked for me was having the EditText requestFocus() after 200 milliseconds, using the postDelayed method of the view