4

I am having a EditText in the hierarchy of

<CoordinateLayout>
...
    <NestedScrollView>
    ...
        <RelativeLayout> <!-- This is inside an included xml layout -->
        ...
            <EditText
                android:id="@+id/rateCalculator"
                android:layout_width="wrap_content"
                android:layout_height="48dp"
                android:background="@color/colorPrimary"
                android:inputType="number"
                android:maxLength="5"
                android:gravity="center"
                android:textColor="#FFFFFF"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true"
                android:paddingLeft="60dp" />
        </RelativeLayout>
    </NestedScrollView>
</CoordinateLayout>

The EditText is being covered by the android soft-keyboard when it is being on focus! So I am unable to see what is being typed while typing!

Update:

This is my manifest code. Doesn't help!

<activity
        android:name=".OfferRide"
        android:label="@string/title_activity_offer_ride"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustPan"
        android:theme="@style/AppTheme.NoActionBar" />

enter image description here

enter image description here

Sibidharan
  • 2,717
  • 2
  • 26
  • 54
  • 1
    Depending on behavior you want to get, you can use android:windowSoftInputMode="adjustResize" or android:windowSoftInputMode="adjustPan" on your activity declaration in Manifest. – andrea.petreri Jan 24 '16 at 09:35

4 Answers4

2

Here is the full doc: http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

android:windowSoftInputMode=["stateUnspecified",
                                       "stateUnchanged", "stateHidden",
                                       "stateAlwaysHidden", "stateVisible",
                                       "stateAlwaysVisible", "adjustUnspecified",
                                       "adjustResize", "adjustPan"] > 

How the main window of the activity interacts with the window containing the on-screen soft keyboard. The setting for this attribute affects two things: The state of the soft keyboard — whether it is hidden or visible — when the activity becomes the focus of user attention. The adjustment made to the activity's main window — whether it is resized smaller to make room for the soft keyboard or whether its contents pan to make the current focus visible when part of the window is covered by the soft keyboard. The setting must be one of the values listed in the following table, or a combination of one "state..." value plus one "adjust..." value. Setting multiple values in either group — multiple "state..." values, for example — has undefined results. Individual values are separated by a vertical bar (|). For example:

<activity android:windowSoftInputMode="stateVisible|adjustResize" . . . >

Values set here (other than "stateUnspecified" and "adjustUnspecified") override values set in the theme.

Flags:

  • "stateUnspecified"
  • "stateUnchanged"
  • "stateHidden" - The state of the soft keyboard — whether it is hidden or visible — when the activity becomes the focus of user attention.
  • "stateAlwaysHidden"
  • "stateVisible"
  • "stateAlwaysVisible"
  • "adjustUnspecified"
  • "adjustResize"

Or sometimes java will do that:

EditText edtView=(EditText)findViewById(R.id.editTextConvertValue);
    edtView.setInputType((InputType.TYPE_NULL);

Take a look:

https://stackoverflow.com/a/6122733/4409113

Community
  • 1
  • 1
ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
2

Removing the gravity from the EditText made it! It seems to be a bug.

<EditText
    android:id="@+id/rateCalculator"
    android:layout_width="wrap_content"
    android:layout_height="48dp"
    android:background="@color/colorPrimary"
    android:inputType="number"
    android:maxLength="5"
    android:textColor="#FFFFFF"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:paddingLeft="60dp" />
Sibidharan
  • 2,717
  • 2
  • 26
  • 54
  • I think it's not a bug, it's a typo mistake or something perhaps you didn't see or mistake on writing, but, my answer worked with removing that gravity? – ʍѳђઽ૯ท Jan 24 '16 at 19:35
  • 3
    Well, nothing works other than removing gravity! I did a research over the internet, and it says this is a bug! @LinX64 thanks for your effort. – Sibidharan Jan 24 '16 at 19:56
  • 1
    Agree that this is a bug. Also I observed that android:inputType and android:gravity cannot be together. So the solution is to remove one of it. – kasurd Sep 09 '16 at 10:19
  • 1
    Also found solution for password inputType. So you can remove android:inputType="textPassword" and set it in code like this: mEtPassword.setTransformationMethod(new PasswordTransformationMethod()); keyboard works fine now – kasurd Sep 14 '16 at 15:31
1

You can try adjustPan, adjustResize options available for windowSoftInputMode in your AndroidManifest as follows:

<activity
    ...
    android:windowSoftInputMode="adjustPan" >
</activity>

You can learn more about it from here

Ichigo Kurosaki
  • 3,765
  • 8
  • 41
  • 56
  • 1
    I think the problem is due to the NoActionBar, theme, making activity fullscreen affects the working of adjustpan, resize.. functionality.. refer this [question](http://stackoverflow.com/questions/4558810/adjustpan-not-preventing-keyboard-from-covering-edittext) – Ichigo Kurosaki Jan 24 '16 at 09:44
0

Depending on behavior you want to get, you can use android:windowSoftInputMode="adjustResize" or android:windowSoftInputMode="adjustPan" on your activity declaration in Manifest.

andrea.petreri
  • 4,137
  • 2
  • 22
  • 21