Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

virtual keyboard covering EditText in Galaxy Tab

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...!

like image 469
rahul Avatar asked Oct 21 '11 11:10

rahul


People also ask

How to hide soft keyboard in Android?

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.

How to show soft keyboard in Android?

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.

What is a soft keyboard Android?

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.


4 Answers

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.

like image 121
Uttam Avatar answered Oct 04 '22 23:10

Uttam


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?

like image 30
aleph_null Avatar answered Oct 04 '22 21:10

aleph_null


Just add
android:windowSoftInputMode=”adjustPan” for your activity in manifest file

like image 28
Rakon_188 Avatar answered Oct 04 '22 23:10

Rakon_188


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.

like image 25
mindriot Avatar answered Oct 04 '22 22:10

mindriot