0

I have a simple layout, shown below:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:fadeScrollbars="false"
        android:gravity="center_vertical" >

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:lineSpacingMultiplier="1.2" />
    </ScrollView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:descendantFocusability="beforeDescendants"
        android:focusableInTouchMode="true"
        android:orientation="vertical" >

        <EditText
            android:layout_width="match_parent"
            android:layout_height="290dp"
            android:ems="10"
            android:gravity="top" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Submit"/>
    </LinearLayout>

</RelativeLayout>

Basically, there is a TextView inside of a ScrollView that states a question, and I want the user to type the answer inside the EditText.

In my AndroidManifest, I've included the following:

<activity
    android:screenOrientation="portrait"
    android:windowSoftInputMode="???" >
</activity>

Where the "???" is, I've tried using the following: adjustPan, adjustResize, and adjustPan|adjustResize.

With adjustPan and adjustResize, I'm experiencing the same thing: when I type and the text gets out of view, the screen automatically scrolls down so the keyboard doesn't cover the text being typed. The problem here, however, is that when I try to highlight the typed text to select all, copy, cut, or paste, the copy/cut/paste menu bar that normally appears on top can't be reached because it's been scrolled out of view. If I try to manually reach that menu bar, then the text no longer gets highlighted.

With adjustPan|adjustResize, the copy/cut/paste menu bar stays happily within view and within reach, but if I type too much, the typed text eventually gets obscured by the keyboard.

So how can I still type where the typed text never gets obscured, and still have the copy/cut/paste menu bar follow along and allow me to make occasional edits as needed?

user2323030
  • 1,153
  • 2
  • 15
  • 35

1 Answers1

0

Turns out, the problem has nothing to do with android:windowsSoftInputMode at all. The copy/cut/paste bar works exactly how it's intended only when the notification bar is visible. When the notification bar is removed, the copy/cut/paste bar behaves erratically.

In order to avoid seeing the obvious black bar on the top, a way to work around this is to use:

View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

So, while it now works, the activity's appearance is not 100% how I would have liked. If anyone has a better workaround than this, please comment.

user2323030
  • 1,153
  • 2
  • 15
  • 35