0

I have this EditText:

<EditText
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/inputText"
    android:inputType="textCapCharacters|textMultiLine"
    android:hint="@string/input_text_hint"
    android:gravity="top|left"/>

When I select it while my phone is horizontal, I see this: enter image description here

But when I select it while my phone is vertical, I see this: enter image description here

When the phone is vertical, I want the "DONE" button to appear like it does when the phone is horizontal.

I also want the return key to move the cursor down a line when its pressed.

How do I do this?

EDIT

Full activity_main.xml in case anyone's wondering...

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
    android:weightSum="18"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="13">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/inputText"
            android:inputType="textCapCharacters|textMultiLine"
            android:hint="@string/input_text_hint"
            android:gravity="top|left"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="2">

        <Button
            android:background="@drawable/main_button"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="@string/big_button"
            android:id="@+id/bigButton"
            android:textSize="68sp"
            android:focusableInTouchMode="false"
            android:fontFamily="sans-serif-black"
            style="@style/button_text"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="3"
        android:clickable="false"></LinearLayout>
</LinearLayout>
Novice coder
  • 163
  • 1
  • 8

2 Answers2

1

When the phone is vertical, I want the "DONE" button to appear like it does when the phone is horizontal.

In landscape, editing an EditText takes up the entire screen; none of the app UI is visible or available for scrolling/tapping. This is why the "DONE" button is displayed only in landscape, so that the user can exit the edit mode and return to the app UI. If you had additional EditText views after the current one, the button would display "NEXT".

In portrait, the app UI is visible, so this button does not display. Instead, the user can take actions directly in the app UI after editing.

I also want the return key to move the cursor down a line when its pressed.

Do you mean insert a newline and then move the cursor down to the new line? If so, your specifying textMultiLine in android:inputType should enable this behavior. What happens when you tap the enter key?

unrulygnu
  • 1,596
  • 13
  • 16
1

When the phone is horizontal, you're in a special mode called "Extract View" where the keyboard draws the entire screen. That's how the keyboard is drawing it. In portrait you are not in extract view, so it will not show that ui. Please note that this behavior varies by keyboard, many keyboards choose not to do extract view, particularly on tablets.

I don't think there is a way to force it to show extract view for portrait- the keyboard decides whether to enter it, and I don't know any keyboard that does it for portrait. If you want that UI you'll have to do it from scratch yourself.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • I'm not sure this is actually the case. The 'Extract View' you refer to is applicable to Fullscreen mode of an IME where the keyboard not only takes up the full width of the screen but also nearly the full height of the screen and the EditText shown is generated by the IME. It's not clear from the OP's post if the "Done" button is part of their layout or if it's auto-created. Unless the OP shows their full layout XML file, it's hard to tell. – Squonk Feb 25 '15 at 04:09
  • I wrote Swype. I recognize the extract view. That's what's happening – Gabe Sechan Feb 25 '15 at 04:12