When comparing our design between developers, we found a strange behavior. After some analysis we went to this observation.
When the activity starts, on some cases the keyboard appears but sometimes not.
In fact, without a ScrollView
, the soft keyboard does not appear by default on an EditText
.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TestActivity" >
<EditText
android:id="@+id/editText1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="text" >
<requestFocus />
</EditText>
</LinearLayout>
But when we add a ScrollView
, the soft keyboard shows up by default.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TestActivity" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" >
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="text" >
<requestFocus />
</EditText>
</ScrollView>
</LinearLayout>
It only depends on the presence of the ScrollView
. We can fix that with a specific declaration in the AndroidManifest
, but this is the default behavior.
I and my fellow developer wonder why is this occurring ?