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...!
Hiding the Soft Keyboard Programmatically You can force Android to hide the virtual keyboard using the InputMethodManager, calling hideSoftInputFromWindow, passing in the token of the window containing your edit field. This will force the keyboard to be hidden in all situations.
SHOW_FORCED,0) toggles the soft keyboard. If you want to make sure that the keyboard appears, you can use imm. showSoftInput( view, InputMethodManager. SHOW_IMPLICIT ) instead, where view is the View that will get the input.
The Android system shows an on-screen keyboard — known as a soft input method — when a text field in your UI receives focus. The keyboard takes about half the screen; in other words, you only have half of the screen to display any information.
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.
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?
Just add
android:windowSoftInputMode=”adjustPan” for your activity in manifest file
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With