1

I use EditText in a fragment which is in a constraintsLayout, but the editText do not move up when I typed more line which is more than the screen length.

I tried setting "windowSoftInputMode" to "adjustPan" and "adjustResize", tried setting "isScrollContainer" true and false.

I tried using a scrollview and set my EditText as its child. But all having same problem.

My activity is not fullscreen.

The code below is my manifest

<activity
        android:name=".MainActivity"
        android:screenOrientation="userPortrait"
        android:windowSoftInputMode="stateVisible|adjustPan">

and the following codes are my layout, it is in a constraints layout.

<EditText
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:inputType="textCapSentences|textAutoCorrect|textMultiLine|textWebEditText"
        android:ems="10"
        android:id="@+id/editText"
        android:imeOptions="actionSend"
        android:scrollHorizontally="false"
        android:saveEnabled="true"
        android:scrollbars="vertical"
        app:layout_constraintTop_toBottomOf="@+id/textView"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginStart="16dp"
        android:layout_marginLeft="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginRight="16dp"
        android:layout_marginTop="32dp"
        app:layout_constraintHorizontal_bias="0.0"
        android:isScrollContainer="false"
        android:scrollbarAlwaysDrawVerticalTrack="true"
        android:hint="@string/writeYourPostHere"/>

This is the appearance of my fragment before typing anything. appearance of my fragment before typing anything

This is the appearance of my fragment when I typed 20 lines of words "testing" with "line number",it did not move up and the remaining words (Testing 18, Testing 19, Testing 20) are hidden even though I am still typing the words "Testing 20". I want it to move up and show the last words I had typed.

enter image description here

I already read the answer in the following link, but they all appeared the same and cannot solve my problem.

EditText, adjustPan, ScrollView issue in android

adjustPan not preventing keyboard from covering EditText

Forcing adjustPan in activity containing ScrollView

Android EditText Multiline with SoftInputMode adjustPan

How to avoid soft keyboard pushing up my layout?

Soft keyboard hides parts of fullscreen webview

Android adjustPan is being ignored

Community
  • 1
  • 1
Hon
  • 110
  • 1
  • 14

1 Answers1

1

I found the answer by using following method.

1)put the scrollview outside the constraintslayout, previously I just use the scrollview with edittext as the only child.

<ScrollView>
    <ConstraintsLayout>
        <EditText>
        </>
    </>
</>

2) For the editText, the setting is

android:imeOptions="flagNoExtractUi"

3) Lastly, i put this code at the onCreateView for the fragment.

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Hon
  • 110
  • 1
  • 14
  • Indeed you can just use getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); to achieve panning on your edittext. You can leave constraint out of the scrollview. – Jose Hidalgo Jun 04 '18 at 08:25