Reputation: 2906
I have a EditText
in my app. my problem is that the the virtual keyboard masks my EditText
while typing. I have tried using different stuffs..
<activity android:name="Myactivity" android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation"
android:windowSoftInputMode="stateVisible|adjustResize"></activity>
but this problem still exists...do any one have any idea how I can make the EditText
go up as I type...?
Happy coding...!
Upvotes: 9
Views: 5821
Reputation: 5786
I had the same issue with a Galaxy. Turns out that Android lets you change the behavior of the soft keyboard. You can find the docs here: http://developer.android.com/resources/articles/on-screen-inputs.html
Working Link: http://android-developers.blogspot.co.il/2009/04/updating-applications-for-on-screen.html
Basically, there are three input modes:
1) Pan and scan: scrolls the application window to make the focused view visible.
2) Resize: application window is resized to fit the focused view
3) Extract mode: landscape only (look at the picture in the docs... it explains it better than i ever could)
By what i've read, pan and scan (which is set by default) and resize don't work for you... even though the first should scroll the application window and the second should resize it to make the EditText visible. Can you post your layout?
Upvotes: 3
Reputation: 14289
Keep the activity settings you posted, in particular:
android:windowSoftInputMode="stateVisible|adjustResize"
Try wrapping a ScrollView around the layout containing the EditText. The top of the ScrollView will need to be higher than the top of the SoftKeyboard. I tested this with many EditTexts in a vertical LinearLayout and found that when the soft keyboard opens, the ScrollView is resized to the visible screen and scrolls as the focus changes to the next EditText. Also know that ScrollViews within ScrollViews will cause problems. Hope this helps.
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="vertical"
>
<EditText
android:layout_width="192dp"
android:layout_height="wrap_content"
android:inputType="textShortMessage"
android:imeOptions="actionNext|flagNoEnterAction"
android:maxLines="1"
android:maxLength="64"
/>
<EditText
android:layout_width="192dp"
android:layout_height="wrap_content"
android:inputType="textShortMessage"
android:imeOptions="actionNext|flagNoEnterAction"
android:maxLines="1"
android:maxLength="64"
/>
<EditText
android:layout_width="192dp"
android:layout_height="wrap_content"
android:inputType="textShortMessage"
android:imeOptions="actionNext|flagNoEnterAction"
android:maxLines="1"
android:maxLength="64"
/>
<EditText
android:layout_width="192dp"
android:layout_height="wrap_content"
android:inputType="textShortMessage"
android:imeOptions="actionNext|flagNoEnterAction"
android:maxLines="1"
android:maxLength="64"
/>
<EditText
android:layout_width="192dp"
android:layout_height="wrap_content"
android:inputType="textShortMessage"
android:imeOptions="actionNext|flagNoEnterAction"
android:maxLines="1"
android:maxLength="64"
/>
<EditText
android:layout_width="192dp"
android:layout_height="wrap_content"
android:inputType="textShortMessage"
android:imeOptions="actionNext|flagNoEnterAction"
android:maxLines="1"
android:maxLength="64"
/>
<EditText
android:layout_width="192dp"
android:layout_height="wrap_content"
android:inputType="textShortMessage"
android:imeOptions="actionNext|flagNoEnterAction"
android:maxLines="1"
android:maxLength="64"
/>
<EditText
android:layout_width="192dp"
android:layout_height="wrap_content"
android:inputType="textShortMessage"
android:imeOptions="actionNext|flagNoEnterAction"
android:maxLines="1"
android:maxLength="64"
/>
<EditText
android:layout_width="192dp"
android:layout_height="wrap_content"
android:inputType="textShortMessage"
android:imeOptions="actionNext|flagNoEnterAction"
android:maxLines="1"
android:maxLength="64"
/>
</LinearLayout>
</ScrollView>
EDIT: Clarified ScrollView position.
Upvotes: 1
Reputation: 4695
In the EditText in layout.xml file, add this line
android:imeOptions="flagNoExtractUi"
Upvotes: -1
Reputation: 573
Just add
android:windowSoftInputMode=”adjustPan” for your activity in manifest file
Upvotes: 2
Reputation: 12399
Just try to do in the Android Manifest file:
android:windowSoftInputMode="stateVisible|adjustResize|adjustPan"
Also you need to add following code in the activity's OnCreate function:
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
I hope this should work for you.
Upvotes: 5